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

filter_log_to_metrics: add new option 'discard_logs' #9150

Merged
merged 1 commit into from
Aug 2, 2024

Conversation

edsiper
Copy link
Member

@edsiper edsiper commented Aug 1, 2024

[updated]

By default, the filter don't drop the logs from the pipeline, there are cases where only metrics are desired to reduce log volume.

This patch introduces a new option called discard_logs (default: false) which when enabled will discard the logs once they are processed.

usage:

service:
  log_level: info

pipeline:
  inputs:
    - name: dummy
      tag: dummy.log
      dummy: '{"message":"dummy", "kubernetes":{"namespace_name": "default", "docker_id":
        "abc123", "pod_name": "pod1", "container_name": "mycontainer", "pod_id": "def456"},
        "duration": 20, "color": "red", "shape": "circle"}'

      processors:
        logs:
          - name: log_to_metrics
            tag: test_metric
            metric_name: count_all_dummy_messages
            metric_mode: counter
            metric_description: This metric counts dummy messages
            discard_logs: true

  outputs:
    - name: prometheus_exporter
      match: '*'
      host: 0.0.0.0
      port: '2021'

    - name: stdout
      match: '*'

In addition, other changes were made:

  • replacement of flb_malloc() with flb_calloc()
  • context structure definition changes: e.g: do not malloc ints
  • fix double free on cmetrics context destroy (histograms)
  • general cleanups...

NOTE: I noticed that record accessor contexts are being created for fixed patterns (e.g: $kubernetes['pod_name']), we will need to fix this since the creation of those contexts are expensive, is times better to have them in the context and use it on demand.


Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

@@ -902,8 +909,7 @@ static int cb_log_to_metrics_filter(const void *data, size_t bytes,
}

ret = flb_input_metrics_append(ctx->input_ins, ctx->tag, strlen(ctx->tag), ctx->cmt);

if (ret != 0) {
if (ret != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this indentation correct?

@edsiper edsiper force-pushed the log-to-metrics-discard-logs branch from 0885027 to 93daf38 Compare August 1, 2024 14:03
@edsiper edsiper force-pushed the log-to-metrics-discard-logs branch from 4e0e77b to f86d39d Compare August 2, 2024 00:38
By default, the filter don't drop the logs from the pipeline, there
are cases where only metrics are desired to reduce log volume.

This patch introduces a new option called discard_logs (default: false)
which when enabled will discard the logs once they are processed.

In addition, other changes were made:

- replacement of flb_malloc() with flb_calloc()
- context structure definition changes: e.g: do not malloc ints
- fix double free on cmetrics context destroy (histograms)
- general cleanups...

NOTE: I noticed that record accessor contexts are being created for fixed
patterns (e.g: $kubernetes['pod_name']), we will need to fix this since
the creation of those contexts are expensive, is times better to have them
in the context and use it on demand.

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants