【问题标题】:Telegraf on Kubernetes: Error: Service "telegraf" is invalid: spec.ports: Required valueKubernetes 上的 Telegraf:错误:服务“telegraf”无效:spec.ports:必需值
【发布时间】:2021-09-07 02:46:17
【问题描述】:

我想做什么?

我正在尝试在我的 Kubernetes 集群中部署 telegraf,以便我可以使用 Telegraf 的 Prometheus 输入插件从特定 URL 读取数据(指标)并使用 telegraf 将指标写入文件输出文件插件。

我做了什么?

我使用 telegraf helm chart 在 kubernetes 上部署 telegraf。 我更改了以下配置更改。 原电报 yaml 文件:

config:
  agent:
    interval: "10s"
    round_interval: true
    metric_batch_size: 1000
    metric_buffer_limit: 10000
    collection_jitter: "0s"
    flush_interval: "10s"
    flush_jitter: "0s"
    precision: ""
    debug: false
    quiet: false
    logfile: ""
    hostname: "$HOSTNAME"
    omit_hostname: false
  processors:
    - enum:
        mapping:
          field: "status"
          dest: "status_code"
          value_mappings:
            healthy: 1
            problem: 2
            critical: 3
  outputs:
    - influxdb:
        urls:
          - "http://influxdb.monitoring.svc:8086"
        database: "telegraf"
  inputs:
    - statsd:
        service_address: ":8125"
        percentiles:
          - 50
          - 95
          - 99
        metric_separator: "_"
        allowed_pending_messages: 10000
        percentile_limit: 1000

我对其所做的更改:

config:
  outputs:
    - file:
        files:
          - "stdout"
          - "metrics.out" 
        data_format: influx  
  inputs:
    - prometheus:
        - urls:
            url: "http://ipaddr:80/metrics"

当我应用 helm 图表以及我得到的更改时 错误:服务“telegraf”无效:spec.ports:必需值,我的部署失败。

chandhana@Azure:~/clouddrive/PromExpose$ helm install telegraf influxdata/telegraf -f telegraf-values.yaml
Error: Service "telegraf" is invalid: spec.ports: Required value

如果我在更改后的 YAML 配置上犯了任何错误,请帮助我,因为我没有找到 Telegraf 输入和输出插件的 yaml 格式的任何资源。 附加链接供参考: telegraf .conf file

【问题讨论】:

    标签: kubernetes prometheus kubernetes-helm telegraf telegraf-plugins


    【解决方案1】:

    您忘记在values.yaml 中启用指标,默认情况下禁用。 正确的部分是

    metrics:
      health:
        enabled: true
      collect_memstats: false
    

    将您的 telegraf-values.yaml 更改为

    config:
      agent:
        interval: "10s"
        round_interval: true
        metric_batch_size: 1000
        metric_buffer_limit: 10000
        collection_jitter: "0s"
        flush_interval: "10s"
        flush_jitter: "0s"
        precision: ""
        debug: false
        quiet: false
        logfile: ""
        hostname: "$HOSTNAME"
        omit_hostname: false
      processors:
        - enum:
            mapping:
              field: "status"
              dest: "status_code"
              value_mappings:
                healthy: 1
                problem: 2
                critical: 3
      outputs:
        - file:
            files:
              - "stdout"
              - "metrics.out" 
            data_format: influx 
      inputs:
        - prometheus:
            - urls:
                url: "http://ipaddr:80/metrics"
    
    metrics:
      health:
        enabled: true
      collect_memstats: false
    

    结果:

    helm install telegraf influxdata/telegraf -f values.yaml
    NAME: telegraf
    LAST DEPLOYED: Fri Jun 25 10:35:05 2021
    NAMESPACE: default
    STATUS: deployed
    REVISION: 1
    TEST SUITE: None
    NOTES:
    To open a shell session in the container running Telegraf run the following:
    
      kubectl exec -i -t --namespace default $(kubectl get pods --namespace default -l app.kubernetes.io/name=telegraf -o jsonpath='{.items[0].metadata.name}') /bin/sh
    
    To view the logs for a Telegraf pod, run the following:
    
      kubectl logs -f --namespace default $(kubectl get pods --namespace default -l app.kubernetes.io/name=telegraf -o jsonpath='{ .items[0].metadata.name }')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-18
      • 2018-11-02
      • 2022-10-21
      • 2017-10-12
      • 2021-01-23
      • 2021-02-25
      相关资源
      最近更新 更多