Replicate LogQL query in Promtail Pipeline stages

Hi Loki team I want to replicate this query in promtail {log_group="/aws/lambda"} | line_format {{ Replace line “\” “” -1 }}`` can somebody please help me I’m stuck at this for a week now, please?

Try this (not tested):

- pipeline_stages:
    - match:
        - selector: {log_group="/aws/lambda"}
          stages:
            - template:
                template: '{{ Replace line "\" "" -1 }}'

You may need to first allocate a label/source for the entire log line.

Can you please share the code for the same also (You may need to first allocate a label/source for the entire log line.) I will try both the cases.

It’s just that you may need to set source for the template stage, and depending on how you parse your message the source can either be the logline or something else.

This is not working !! I tried but template function is not working here is my config

scrape_configs:

  • job_name: apache_vm
    pipeline_stages:
    • match:
      selector: ‘{job=“apache”}’
      action: “keep”
      stages:
      - regex:
      expression: ‘^(?P.*)$’
      - template:
      source: ‘line’
      template: ‘{{ .line | replace “-” “” -1 }}’

How about the replace stage?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.