VictoriaMetrics / ansible-playbooks

Ansible Playbooks for Victoria Metrics monorepo
Apache License 2.0
99 stars 34 forks source link

How correct set vmagent_scrape_config ? #22

Closed patsevanton closed 2 years ago

patsevanton commented 2 years ago

Hello! Thanks for roles vm

I try install vmagent by ansible and get error

Inventory

all:
  children:
    vm-single:
      hosts:
        "victoriametrics":
          ansible_host: "xxxx"
  vars:
    ansible_user:  ubuntu
    ansible_ssh_private_key_file: ~/.ssh/id_rsa
    vmagent_scrape_config:
      node:
      - targets:
        - localhost:9100
    prometheus_components: [ "prometheus", "node_exporter" ]
.....

Playbook

---
- hosts: vm-single
  collections:
    - victoriametrics.cluster
  become: true
  roles:
    - role: cloudalchemy.node_exporter
    - role: victoriametrics.cluster.vmagent

ansible error

TASK [victoriametrics.cluster.vmagent : Ensure vic-vmagent service started] ************************************************************************************************************
Monday 11 April 2022  18:36:37 +0600 (0:00:01.264)       0:00:59.164 **********
fatal: [victoriametrics]: FAILED! => changed=false
  msg: |-
    Unable to start service vic-vmagent: Job for vic-vmagent.service failed because the control process exited with error code.
    See "systemctl status vic-vmagent.service" and "journalctl -xe" for details.

systemctl status vic-vmagent

● vic-vmagent.service - Description=VictoriaMetrics vmagent service
     Loaded: loaded (/etc/systemd/system/vic-vmagent.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Mon 2022-04-11 12:36:39 UTC; 1min 0s ago
    Process: 1677 ExecStart=/usr/local/bin/vmagent-prod --remoteWrite.url=http://localhost:8428/api/v1/write --promscrape.config=/opt/vic-vmagent/config.yml --remoteWrite.tmpDataPath=>
   Main PID: 1677 (code=exited, status=255/EXCEPTION)

Apr 11 12:36:39 victoriametrics systemd[1]: vic-vmagent.service: Scheduled restart job, restart counter is at 5.
Apr 11 12:36:39 victoriametrics systemd[1]: Stopped Description=VictoriaMetrics vmagent service.
Apr 11 12:36:39 victoriametrics systemd[1]: vic-vmagent.service: Start request repeated too quickly.
Apr 11 12:36:39 victoriametrics systemd[1]: vic-vmagent.service: Failed with result 'exit-code'.
Apr 11 12:36:39 victoriametrics systemd[1]: Failed to start Description=VictoriaMetrics vmagent service.
Apr 11 12:36:39 victoriametrics systemd[1]: vic-vmagent.service: Start request repeated too quickly.
Apr 11 12:36:39 victoriametrics systemd[1]: vic-vmagent.service: Failed with result 'exit-code'.
Apr 11 12:36:39 victoriametrics systemd[1]: Failed to start Description=VictoriaMetrics vmagent service.

cat /opt/vic-vmagent/config.yml

#Ansible managed

node:
-   targets:
    - localhost:9100
zekker6 commented 2 years ago

Please, take a look at prometheus documentation for scrape_config - https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config

VMagent uses same format for config as described here - https://docs.victoriametrics.com/vmagent.html#how-to-collect-metrics-in-prometheus-format

Default value for this variable is:

vmagent_scrape_config:
  scrape_configs:
    - job_name: localhost
      static_configs:
        - targets: []
#          - "127.0.0.1:9100"

Where you will need to add your jobs and respective targets to scrape_configs section.

patsevanton commented 2 years ago

Thanks!