Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syslog-ng custom log metrics #1554

Merged
merged 10 commits into from
Nov 1, 2023
Merged

syslog-ng custom log metrics #1554

merged 10 commits into from
Nov 1, 2023

Conversation

pepov
Copy link
Member

@pepov pepov commented Oct 24, 2023

SyslogNG custom source and output metrics

Source metrics are put after the json parser.

kind: Logging
apiVersion: logging.banzaicloud.io/v1beta1
metadata:
  name: logging
spec:
  controlNamespace: default
  fluentbit: {}
  syslogNG:
    metrics: {}
    sourceMetrics:
      - key: custom_input
        labels:
          test: asd

Results in:

source "main_input" {
    channel {
        source {
            network(flags("no-parse") port(601) transport("tcp") max-connections(100) log-iw-size(10000));
        };
        parser {
            json-parser(prefix("json."));
            metrics-probe(key("custom_input") labels(
                "logging" => "logging"
                "test" => "asd"
            ));
        };
    };
};

Output metrics are put before the log reaches the destination and is decorated with the output metadata like: name, namespace and scope which holds whether the output is a local or global one.

apiVersion: logging.banzaicloud.io/v1beta1
kind: SyslogNGFlow
metadata:
  name: all1
spec:
  match: {}
  outputMetrics:
    - key: custom_output
      labels:
        flow: all1
  localOutputRefs:
    - http
  globalOutputRefs:
    - http2

Becomes:

filter "flow_default_all1_ns_filter" {
    match("default" value("json.kubernetes.namespace_name") type("string"));
};
log {
    source("main_input");
    filter("flow_default_all1_ns_filter");
    log {
        parser {
            metrics-probe(key("custom_output") labels(
                "flow" => "all1"
                "logging" => "logging"
                "output_name" => "http2"
                "output_namespace" => "default"
                "output_scope" => "global"
            ));
        };
        destination("clusteroutput_default_http2");
    };
    log {
        parser {
            metrics-probe(key("custom_output") labels(
                "flow" => "all1"
                "logging" => "logging"
                "output_name" => "http"
                "output_namespace" => "default"
                "output_scope" => "local"
            ));
        };
        destination("output_default_http");
    };
};

Metrics:

k curl logging-syslog-ng-0:9577/metrics  | grep custom_
# TYPE syslogng_custom_output gauge
syslogng_custom_output{flow="all1",logging="logging",output_name="http2",output_namespace="default",output_scope="global"} 42
syslogng_custom_output{flow="all1",logging="logging",output_name="http",output_namespace="default",output_scope="local"} 42
syslogng_custom_output{flow="all2",logging="logging",output_name="http2",output_namespace="default",output_scope="global"} 154
# TYPE syslogng_custom_input gauge
syslogng_custom_input{logging="logging"} 154

@pepov pepov changed the title syslog ng metrics syslog ng flow metrics Oct 24, 2023
@pepov pepov changed the title syslog ng flow metrics syslog ng log metrics Oct 24, 2023
@pepov pepov force-pushed the syslog-ng-metrics branch 3 times, most recently from 79f6484 to 35e32ce Compare October 27, 2023 14:31
@pepov pepov marked this pull request as ready for review October 27, 2023 14:36
@pepov pepov changed the title syslog ng log metrics syslog-ng custom log metrics Oct 27, 2023
@pepov pepov requested a review from orymate October 27, 2023 14:43
Copy link
Contributor

@siliconbrain siliconbrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

pkg/sdk/logging/model/syslogng/config/config.go Outdated Show resolved Hide resolved
@pepov pepov force-pushed the syslog-ng-metrics branch from 218096c to 3f31b3d Compare October 31, 2023 09:12
@pepov
Copy link
Member Author

pepov commented Oct 31, 2023

Update: based on @tarokkk's request logging name is now part of the automatic metric labels

@pepov pepov merged commit 21fed08 into master Nov 1, 2023
17 checks passed
@pepov pepov deleted the syslog-ng-metrics branch November 1, 2023 18:35
@pepov pepov added the enhancement New feature or request label Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants