go-prometheus-client-example

module
v0.0.0-...-533540b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2023 License: MIT

README

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.

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL