hive collector runs only on hive hosts; review classifier pushes metrics through its forwarder
This commit is contained in:
parent
03796f1964
commit
0cbfa806d3
9 changed files with 191 additions and 98 deletions
|
|
@ -101,6 +101,20 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
otlpMetricsPort = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.port;
|
||||
default = null;
|
||||
example = 4318;
|
||||
description = ''
|
||||
When set, the collector also takes OTLP/HTTP metrics on
|
||||
`127.0.0.1:<port>` inside this container and pushes them to
|
||||
{option}`services.hyperhive.swarmJournalForwarder.endpoint` under the
|
||||
same OIDC client as the logs. For a process in the container that
|
||||
speaks OTLP but cannot fetch a token. Null: the collector reads the
|
||||
journal and nothing else.
|
||||
'';
|
||||
};
|
||||
|
||||
hostSecretFile = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
|
|
@ -176,76 +190,89 @@ in
|
|||
# A parser, not a wiring check: it accepts an extension that is never
|
||||
# started.
|
||||
validateConfigFile = true;
|
||||
settings = {
|
||||
# The receiver's read cursor, so a restart resumes rather than skipping
|
||||
# what was written while it was down. `create_directory`, because
|
||||
# `otelcol validate` runs in the build sandbox before systemd's
|
||||
# `StateDirectory=` exists.
|
||||
extensions.file_storage = {
|
||||
directory = "/var/lib/opentelemetry-collector";
|
||||
create_directory = true;
|
||||
};
|
||||
settings = lib.mkMerge [
|
||||
{
|
||||
# The receiver's read cursor, so a restart resumes rather than skipping
|
||||
# what was written while it was down. `create_directory`, because
|
||||
# `otelcol validate` runs in the build sandbox before systemd's
|
||||
# `StateDirectory=` exists.
|
||||
extensions.file_storage = {
|
||||
directory = "/var/lib/opentelemetry-collector";
|
||||
create_directory = true;
|
||||
};
|
||||
|
||||
receivers.journald = {
|
||||
# ⚠️ Stated: the receiver's default is the runtime journal under
|
||||
# /run/log/journal, which is empty when journald stores persistently.
|
||||
directory = "/var/log/journal";
|
||||
# Without `--merge`, `journalctl --follow` over a journal with no
|
||||
# entry for the current boot crash-loops the receiver.
|
||||
merge = true;
|
||||
storage = "file_storage";
|
||||
};
|
||||
receivers.journald = {
|
||||
# ⚠️ Stated: the receiver's default is the runtime journal under
|
||||
# /run/log/journal, which is empty when journald stores persistently.
|
||||
directory = "/var/log/journal";
|
||||
# Without `--merge`, `journalctl --follow` over a journal with no
|
||||
# entry for the current boot crash-loops the receiver.
|
||||
merge = true;
|
||||
storage = "file_storage";
|
||||
};
|
||||
|
||||
processors.resource.attributes = [
|
||||
{
|
||||
key = "service.name";
|
||||
value = cfg.serviceName;
|
||||
action = "upsert";
|
||||
}
|
||||
];
|
||||
processors.resource.attributes = [
|
||||
{
|
||||
key = "service.name";
|
||||
value = cfg.serviceName;
|
||||
action = "upsert";
|
||||
}
|
||||
];
|
||||
|
||||
exporters.otlphttp = {
|
||||
endpoint = cfg.endpoint;
|
||||
# The receiver accepts an OIDC token and nothing else.
|
||||
auth.authenticator = authName;
|
||||
};
|
||||
exporters.otlphttp = {
|
||||
endpoint = cfg.endpoint;
|
||||
# The receiver accepts an OIDC token and nothing else.
|
||||
auth.authenticator = authName;
|
||||
};
|
||||
|
||||
extensions.${authName} = {
|
||||
client_id = cfg.clientId;
|
||||
# A path systemd resolves at runtime, so neither the secret nor the
|
||||
# credentials directory is rendered into the nix store.
|
||||
client_secret_file = "\${env:CREDENTIALS_DIRECTORY}/${credentialId}";
|
||||
token_url = cfg.tokenUrl;
|
||||
# ⚠️ Requested, not merely registered: a token minted without asking
|
||||
# carries `aud: []` and the receiver refuses it.
|
||||
endpoint_params.audience = cfg.clientId;
|
||||
};
|
||||
extensions.${authName} = {
|
||||
client_id = cfg.clientId;
|
||||
# A path systemd resolves at runtime, so neither the secret nor the
|
||||
# credentials directory is rendered into the nix store.
|
||||
client_secret_file = "\${env:CREDENTIALS_DIRECTORY}/${credentialId}";
|
||||
token_url = cfg.tokenUrl;
|
||||
# ⚠️ Requested, not merely registered: a token minted without asking
|
||||
# carries `aud: []` and the receiver refuses it.
|
||||
endpoint_params.audience = cfg.clientId;
|
||||
};
|
||||
|
||||
service.pipelines.logs = {
|
||||
receivers = [ "journald" ];
|
||||
processors = [ "resource" ];
|
||||
exporters = [ "otlphttp" ];
|
||||
};
|
||||
service.pipelines.logs = {
|
||||
receivers = [ "journald" ];
|
||||
processors = [ "resource" ];
|
||||
exporters = [ "otlphttp" ];
|
||||
};
|
||||
|
||||
# ⚠️ `readers`, not `metrics.address`: this collector version rejects
|
||||
# `address` at startup.
|
||||
service.telemetry.metrics.readers = [
|
||||
{
|
||||
pull.exporter.prometheus = {
|
||||
host = "127.0.0.1";
|
||||
port = cfg.telemetryPort;
|
||||
};
|
||||
}
|
||||
];
|
||||
# ⚠️ `readers`, not `metrics.address`: this collector version rejects
|
||||
# `address` at startup.
|
||||
service.telemetry.metrics.readers = [
|
||||
{
|
||||
pull.exporter.prometheus = {
|
||||
host = "127.0.0.1";
|
||||
port = cfg.telemetryPort;
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
# An extension not listed here is inert: the receiver's storage would
|
||||
# name a component that never starts, and the exporter would push
|
||||
# unauthenticated.
|
||||
service.extensions = [
|
||||
"file_storage"
|
||||
authName
|
||||
];
|
||||
};
|
||||
# An extension not listed here is inert: the receiver's storage would
|
||||
# name a component that never starts, and the exporter would push
|
||||
# unauthenticated.
|
||||
service.extensions = [
|
||||
"file_storage"
|
||||
authName
|
||||
];
|
||||
}
|
||||
# A separate set the module system merges in: joining it to the first with
|
||||
# `//` would replace the first set's whole `service` attrset.
|
||||
(lib.mkIf (cfg.otlpMetricsPort != null) {
|
||||
receivers.otlp.protocols.http.endpoint = "127.0.0.1:${toString cfg.otlpMetricsPort}";
|
||||
# No `resource` processor: it upserts the journal's `service.name`, and
|
||||
# the sender names itself.
|
||||
service.pipelines.metrics = {
|
||||
receivers = [ "otlp" ];
|
||||
exporters = [ "otlphttp" ];
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
# `Restart` is nixpkgs' `"always"`; a second definition conflicts. Only
|
||||
|
|
|
|||
Loading…
Reference in a new issue