【问题标题】:Helm Loki Stack additional promtail configHelm Loki Stack 附加 promtail 配置
【发布时间】:2022-09-24 04:04:11
【问题描述】:

我使用 helm 安装 loki 和 prometheus。 但是,我想在一个地方替换日志。 我使用: helm show values grafana/loki-stack > loki-stack-values.yml 输出值并得出以下结果:

loki:
  enabled: true
  isDefault: true

promtail:
  enabled: true
  config:
    lokiAddress: http://{{ .Release.Name }}:3100/loki/api/v1/push
      prometheusSpec:
        additionalScrapeConfigs:
          - match:
              selector: \'{name=\"promtail\"}\'
              stages:
              # The regex stage parses out a level, timestamp, and component. At the end
              # of the stage, the values for level, timestamp, and component are only
              # set internally for the pipeline. Future stages can use these values and
              # decide what to do with them.
              - regex:
                  expression: \'.*level=(?P<level>[a-zA-Z]+).*ts=(?P<timestamp>[T\\d-:.Z]*).*component=(?P<component>[a-zA-Z]+)\'



实际上,一切都会很好。但是我的输出真的很奇怪所以我尝试添加 additionalScrapeConfigs

2022-05-06 18:31:55 
{\"log\":\"2022-05-06T18:31:55,003 \\u001b[36mDEBUG\\u001b[m

所以对于这个问题:

如何使用 helm install dlp-dev-loki grafana/loki-stack --values loki-stack-values.yml -n dev。以及 promtail 的其他 scape 配置。

    标签: kubernetes kubernetes-helm grafana promtail


    【解决方案1】:

    根据文档promtail pipelines,时间戳阶段采用从正则表达式阶段提取的时间戳并将其提升为日志条目的新时间戳,时间戳应将其解析为 RFC3339Nano 格式的值。将以下内容添加到正则表达式下方的配置文件中。

    - timestamp:
        format: RFC3339Nano
        source: timestamp
    

    【讨论】:

      猜你喜欢
      • 2023-02-06
      • 2023-04-04
      • 2022-07-29
      • 2023-02-07
      • 2022-06-20
      • 2021-02-02
      • 2022-08-11
      • 2023-02-15
      • 2022-12-10
      相关资源
      最近更新 更多