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

fix: disable long lines splitting in promtail_config_scrape_configs #197

Merged
merged 1 commit into from
Nov 5, 2023

Conversation

niasar
Copy link
Contributor

@niasar niasar commented Nov 1, 2023

In some cases to_nice_yaml splitting long lines (>80 symbols) incorrectly.

Example

This block in promtail_config_scrape_configs :

  - job_name: nginx-access
    static_configs:
    - targets:
        - localhost
      labels:
        job: nginx-access
        __path__: <path>
    pipeline_stages:
      - json:
          expressions:
            time_local: time
            remote_addr: remote_addr
            method: method
            path: path
            query: request_query
            status: status
            bytes_sent: bytes_sent
            body_bytes_sent: body_bytes_sent
            upstream_time: upstream_time
            request_time: request_time
            host: host
            protocol: request_proto
            http_user_agent: http_user_agent
          drop_malformed: true
      - labels:
          host:
          path:
          status:
          method:
      - template:
          source: out_msg
          template: '{% raw %}{{ .remote_addr }} {{ .protocol }} {{ .method }} {{ .host }}{{ .path }}{{ if ne .query "-" }}?{{ .query }}{{ end }} {{ .status }} {{ .body_bytes_sent }} {{ .upstream_time }} {{ .request_time }} {{ .http_user_agent }}{% endraw %}'
      - timestamp:
          source: time_local
          format: RFC3339
      - output:
          source: out_msg

Will be rendered as:

  - job_name: nginx-access
    pipeline_stages:
    - json:
        drop_malformed: true
        expressions:
          body_bytes_sent: body_bytes_sent
          bytes_sent: bytes_sent
          host: host
          http_user_agent: http_user_agent
          method: method
          path: path
          protocol: request_proto
          query: request_query
          remote_addr: remote_addr
          request_time: request_time
          status: status
          time_local: time
          upstream_time: upstream_time
    - labels:
        host: null
        method: null
        path: null
        status: null
    - template:
        source: out_msg
        template: '{{ .remote_addr }} {{ .protocol }} {{ .method }} {{ .host }}{{ .path
          }}{{ if ne .query "-" }}?{{ .query }}{{ end }} {{ .status }} {{ .body_bytes_sent
          }} {{ .upstream_time }} {{ .request_time }} {{ .http_user_agent }}'
    - timestamp:
        format: RFC3339
        source: time_local
    - output:
        source: out_msg
    static_configs:
    - labels:
        __path__: <path>
        job: nginx-access
      targets:
      - localhost

With splitting template in multiple, which is not valid promtail config

To fix this I have added width parameter for promtail_config_scrape_configs in config template to disable line splitting.

Closes #196

@patrickjahns patrickjahns added the bug Something isn't working label Nov 1, 2023
@patrickjahns patrickjahns merged commit d534aaa into patrickjahns:master Nov 5, 2023
15 checks passed
@github-actions github-actions bot mentioned this pull request Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unable to parse syslog config receiver
2 participants