n3v3rf411 / go-prometheus-client-example

Sample on querying metrics from prometheus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go Prometheus Client Example

This is an example of a web app that queries a Prometheus server. Originally intended as a proof-of-concept for querying the Prometheus server in the using Rancher's cluster monitoring, this can also be applied to other Prometheus instances that optionally have basic authentication.

The web app uses Echo.

Getting Started

For development, using dotenv is recommended for configuration. In production, this can be replaced with docker-compose environment or kubernetes config map.

cp .env.example .env
  • PROMETHEUS_URL: Prometheus URL
  • PROMETHEUS_AUTH_USERNAME: Optional basic auth username
  • PROMETHEUS_AUTH_PASSWORD: Optional basic auth password

The project comes with basic support for docker container development and deployment. This is optional.

cd docker
cp .env.example .env
docker-compose up -d

Reflex will automatically reload the server if there are changes in .go or .html files.

Rancher Cluster Monitoring

A step-by-step guide can be found at https://hellowillie.com/2020/01/17/sample-go-web-app-for-querying-rancher-cluster-monitoring-prometheus/

To query the Prometheus instance deployed with Rancher's cluster monitoring:

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Sample on querying metrics from prometheus

License:MIT License


Languages

Language:Go 50.8%Language:Shell 21.0%Language:HTML 17.5%Language:Dockerfile 10.7%