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

[exporter/Loki] multiple attributes for loki not working #21168

Closed
saritatewari4 opened this issue Apr 25, 2023 · 5 comments
Closed

[exporter/Loki] multiple attributes for loki not working #21168

saritatewari4 opened this issue Apr 25, 2023 · 5 comments
Labels
exporter/loki Loki Exporter question Further information is requested

Comments

@saritatewari4
Copy link

saritatewari4 commented Apr 25, 2023

Component(s)

exporter/loki

Describe the issue you're reporting

Hello,

I am trying to set multiple labels in loki dashboard, but it's are not working. In the below configuration one label at a time is working but both of them not working together. I can always see app-name in loki dashboard, and if I am adding only traceId id as a label then I can see traceId label after removing app_name.This app_name and traceId I am setting from flauntD manifest file

config.yaml: |
    receivers:
      otlp:
        protocols:
          grpc:
          http:
      fluentforward:
        endpoint: 0.0.0.0:8006
    exporters:
      otlp:
        endpoint: http://tempo
        tls:
          insecure: true  
      logging:
        logLevel: "INFO"
        verbosity: detailed
      loki:
        endpoint: http://loki:3100/loki/api/v1/push
        tls:
          insecure: true
    processors:
      batch:
      attributes:
        actions:
          - action: insert
            key: loki.attribute.labels
            value: app_name
          - action: insert
            key: loki.attribute.labels
            value: traceId
    service:
      pipelines:
        traces:
          receivers: [otlp]
          exporters: [otlp]
        logs:
          receivers: [ fluentforward ]
          processors: [ attributes, batch  ]
          exporters: [ logging, loki ]

This is my loki dashboard:

Screenshot 2023-04-25 at 8 36 09 PM

Please help me where the configuration is wrong.

@saritatewari4 saritatewari4 added the needs triage New item requiring triage label Apr 25, 2023
@github-actions github-actions bot added the exporter/loki Loki Exporter label Apr 25, 2023
@github-actions
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@mar4uk
Copy link
Contributor

mar4uk commented Apr 26, 2023

the attributes processor should look like this:

    processors:
      batch:
      attributes:
        actions:
          - action: insert
            key: loki.attribute.labels
            value: app_name, traceId

To promote multiple attributes to labels you need to specify them coma-separated in one action
I will update README to mention this case.

By the way, traceID is not a good candidate to label promotion. Its value doesn't have boundaries (there are infinite values of traceIDs) which leads to high cardinality issue in Loki.

The best practice is to use filter expressions to query logs for a specific traceID:

{app_name="my-app"} |= “traceID=2612c3ff044b7d02”

A few articles on Loki labels:
https://grafana.com/docs/loki/latest/best-practices/
https://grafana.com/blog/2020/08/27/the-concise-guide-to-labels-in-loki/

@saritatewari4
Copy link
Author

@mar4uk Thank you so much for your response. I was planning to change trace id to correlation Id.

I will definitely follow the best practices which you have shared.

Thanks again.

@mar4uk
Copy link
Contributor

mar4uk commented Apr 26, 2023

Another way to correlate logs and traces is configuring Derived fields in Loki datasource configuration:
https://grafana.com/docs/grafana/latest/datasources/loki/#configure-derived-fields

This will parse the log message, find traceID and make it a link to the tracing datasource:
image

@JaredTan95 JaredTan95 added question Further information is requested and removed needs triage New item requiring triage labels Apr 28, 2023
@jpkrohling
Copy link
Member

Should this be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exporter/loki Loki Exporter question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants