Home > Blockchain >  Why does the grafana agent refuse to start?
Why does the grafana agent refuse to start?

Time:08-13

I set up grafana cloud and connected the apache http server integration, when I try to start, I get an error. I read the documentation, but unfortunately I did not learn anything sensible

error loading config file /etc/grafana-agent.yaml: yaml: unmarshal errors: line 12: field apache_http not found in type integrations.ManagerConfig /etc/grafana-agent.yaml

  agent:
    enabled: true
    metric_relabel_configs:
    - source_labels:
      - exported_job
      target_label: job
    - source_labels:
      - exported_instance
      target_label: instance
    - action: labeldrop
      regex: (exported_instance|exported_job)
  apache_http:
    enabled: true
    instance: <yourhostname>
    scrape_uri: http://localhost:9090/server-status?auto
  node_exporter:
    enabled: true
    relabel_configs:
    - replacement: hostname
      target_label: instance
  prometheus_remote_write:
  - basic_auth:
      password: test
      username: test
    url: test
logs:
  configs:
  - clients:
    - basic_auth:
        password: test
        username: test
      url: test
    name: integrations
    positions:
      filename: /tmp/positions.yaml
    scrape_configs:
    - job_name: integrations/node_exporter_journal_scrape
      journal:
        labels:
          instance: hostname
          job: integrations/node_exporter
        max_age: 24h
      relabel_configs:
      - source_labels:
        - __journal__systemd_unit
        target_label: unit
      - source_labels:
        - __journal__boot_id
        target_label: boot_id
      - source_labels:
        - __journal__transport
        target_label: transport
      - source_labels:
        - __journal_priority_keyword
        target_label: level
    - job_name: integrations/apache_error
      pipeline_stages:
      - regex:
          expression: '^\[[^ ]* (?P<timestamp>[^\]]*)\] \[(?:(?P<module>[^:\]] ):)?(?P<level>[^\]] )\](?: \[pid (?P<pid>[^\]]*)\])?(?: \[client (?P<client>[^\]]*)\])? (?P<message>.*)$'
      - labels:
          level: null
          module: null
      - static_labels:
          logtype: error
      static_configs:
      - labels:
          __path__: /var/log/httpd/error.log
          instance: <yourhostname>
          job: integrations/apache_http
        targets:
        - localhost
    - job_name: integrations/apache_access
      pipeline_stages:
      - regex:
          expression: '^(?P<ip>[^ ]*) [^ ]* (?P<user>[^ ]*) \[(?P<timestamp>[^\]]*)\] "(?P<method>\S )(?:  (?P<path>[^ ]*)  \S*)?" (?P<code>[^ ]*) (?P<size>[^ ]*)(?: "(?P<referer>[^\"]*)" "(?P<agent>.*)")?$'
      - metrics:
          response_http_codes:
            config:
              buckets:
              - 199
              - 299
              - 399
              - 499
              - 599
            description: Apache responses by HTTP codes
            prefix: apache_
            source: code
            type: Histogram
      - labels:
          method: null
      - static_labels:
          logtype: access
      static_configs:
      - labels:
          __path__: /var/log/httpd/access.log
          instance: <yourhostname>
          job: integrations/apache_http
        targets:
        - localhost
    target_config:
      sync_period: 10s
metrics:
  configs:
  - name: integrations
    remote_write:
    - basic_auth:
        password: test
        username: test
      url: test
  global:
    scrape_interval: 60s
  wal_directory: /tmp/grafana-agent-wal```

CodePudding user response:

It's bug in source and fixed in new release, but cloud use old version config. Download installer and do manually

wget https://raw.githubusercontent.com/grafana/agent/release/production/grafanacloud-install.sh

and change line:

RELEASE_VERSION="0.25.1"

to latest https://github.com/grafana/agent/releases/

then do to make it executable

chmod  x grafanacloud-install.sh

and run install like they propose just change command from curl to local script:

sudo ARCH=amd64 GCLOUD_STACK_ID="***" GCLOUD_API_KEY="***" GCLOUD_API_URL="***" /bin/sh -c "./grafanacloud-install.sh"
  • Related