This is a Go application used to discover Virtual Machine (VM) IPs in vCenter and return a JSON for Prometheus file service discovery.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Go (version 1.16 or later)
- Docker (optional)
- Clone the repository:
git clone <repository_url>- Navigate to the project directory:
cd <project_directory>
- Install the dependencies:
go mod download
go run .
The application uses environment variables for configuration. The following environment variables are required:
-
VC_HOST: The vCenter host. -
VC_USER: The vCenter username. -
VC_PASSWORD: The vCenter password. -
PORT: The port on which the application will run. The application also accepts the following flags: -
-tls: Enable TLS. Default isfalse.
The application has a Prometheus controller defined in controller/prom.go. This controller handles the /prom endpoint and is responsible for returning the JSON for Prometheus file service discovery.
The vCenter helper defined in vcenter-helper/vcenter-helper.go is responsible for discovering VM IPs in vCenter.
A Dockerfile is provided if you wish to build a Docker image of the application.
localhost:<port>/<path>
port: This is set as an environment variablepath: This is the path to vCenter folder that you want to scrape. Keep in mind that this discovers the folder recursively.