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

vmware-exporter docker two instances vsphere #393

Open
miavi opened this issue Apr 4, 2024 · 3 comments
Open

vmware-exporter docker two instances vsphere #393

miavi opened this issue Apr 4, 2024 · 3 comments

Comments

@miavi
Copy link

miavi commented Apr 4, 2024

Hi good day to all.

I currently have 1 docker container (https://hub.docker.com/r/pryorda/vmware_exporter) configured for 2 vsphere instances

The problem I have is that the data is interleaved when the 2 instances are active in the Prometheus job (with only 1 instance this problem does not exist)

this is the configuration

docker-compose.yaml

vmware-exporter
container_name: vmware-exporter
hostname: vmware-exporter
image: pryorda/vmware_exporter:v0.18.4
volumes:
./config.yml:/opt/vmware/config.yml
coomand: ["-c", "config.yml}

config.yml

default:
    vsphere_host: "x.x.x.x."
    vsphere_user: "user"
    vsphere_password: "password"
    ignore_ssl: True
    specs_size: 5000
    fetch_custom_attributes: True
    fetch_tags: True
    fetch_alarms: True
    collect_only:
        vms: True
        vmguests: True
        datastores: True
        hosts: True
        snapshots: True
        
  cpd2:
    vsphere_host: "y.y.y.y"
    vsphere_user: "user"
    vsphere_password: "password"
    ignore_ssl: True
    specs_size: 5000
    fetch_custom_attributes: True
    fetch_tags: True
    fetch_alarms: True
    collect_only:
        vms: True
        vmguests: True
        datastores: True
        hosts: True
        snapshots: True

prometheus job

- job_name: vmware_export
scrape_timeout: 40s
scrape_interval: 40s    
metrics_path: /metrics
scheme: "https"
tls_config:
       insecure_skip_verify: true
 static_configs:
 - targets:
      - x.x.x.x
      - y.y.y.y
    relabel_configs:
    - source_labels: [__address__]
      target_label: __param_target
    - source_labels: [__param_target]
      target_label: instance
    - target_label: __address__
      replacement: DNS_vmware_exporter:port

When I perform a query with Prometheus, for example "vmware_host_hardware_info" it shows me in the x.x.x.x instance the hostname of y.y.y.y and vice versa, it is as if the metrics were mixed

On the other hand, if I set up two independent containers (on a different port), each container pointing to 1 vsphere host and then 2 different jobs in Prometheus, this problem does not occur.

Even when the config.yml only has a "default" section and is not multi-room, it works correctly and does not mix the data

It could be a bug when configuring a .yml file with vsphere multistay

In advanced very thanks

@miavi miavi changed the title vmware docker two instances vsphere vmware-exporter docker two instances vsphere Apr 4, 2024
@mbrother2
Copy link

Hi miavi,

You can access second host with URL http://YOUR_IP:9275/metrics?section=cpd2

@chinotseng
Copy link

chinotseng commented May 31, 2024

My configuration file is as follows, and it works fine. ( Thank you mbrother2, for pointing out the key point. )

vmware_exporter config.yml

default:
    vsphere_host: "192.168.1.4"
    vsphere_user: "[email protected]"
    vsphere_password: "PASSWORD"
    ignore_ssl: True
    specs_size: 2000
    fetch_custom_attributes: True
    fetch_tags: True
    fetch_alarms: True
    collect_only:
        vms: True
        vmguests: True
        datastores: True
        hosts: True
        snapshots: True

vc02:
    vsphere_host: "192.168.2.2"
    vsphere_user: "[email protected]"
    vsphere_password: "PASSWORD"
    ignore_ssl: True
    specs_size: 2000
    fetch_custom_attributes: True
    fetch_tags: True
    fetch_alarms: True
    collect_only:
        vms: True
        vmguests: True
        datastores: True
        hosts: True
        snapshots: True

prometheus.yml

  - job_name: 'vmware_exporter'
    scrape_interval: 1m
    scrape_timeout: 1m
    metrics_path: '/metrics'
    static_configs:
      - targets:
        - '192.168.1.4'
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 127.0.0.1:9272

  - job_name: 'vc02'
    static_configs:
      - targets:
        - '127.0.0.1:9272'
    params:
      section: ['vc02']

@miavi
Copy link
Author

miavi commented May 31, 2024

Thank you both very much for the information, I will try this configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants