Skip to content

Commit

Permalink
fix: need to actually load prometheus_url from env
Browse files Browse the repository at this point in the history
  • Loading branch information
kashalls committed Dec 15, 2023
1 parent de5f994 commit d8cf73f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ It allows you to define your own metric names and your own prometheus queries as
You can use [shields.io](https://sheilds.io) and use either the [Dynamic JSON Badge](https://shields.io/badges/dynamic-json-badge) or the [Endpoint Badge](https://shields.io/badges/endpoint-badge) and add dynamic coloring with ranges you set.

[Config Example](./config.yaml.example)
- Reads configuration file from `/config/config.yaml`
- Requires `PROMETHEUS_URL` be set in ENV.
- Optional `PORT` to change server port.

## Performance

Expand Down
10 changes: 8 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type MetricResult struct {
}


var configPath = "config.yaml.example" // Default config file path
var configPath = "/config/config.yaml" // Default config file path

func main() {
// Check if a custom config file path is provided via command line argument
Expand All @@ -58,9 +58,15 @@ func main() {
os.Exit(1)
}

prometheusURL := os.Getenv("PROMETHEUS_URL")

if prometheusURL == "" {
panic("PROMETHEUS_URL is not set")
}

// Create a Prometheus API client
client, err := api.NewClient(api.Config{
Address: "https://prometheus.ok8.sh", // Replace with your Prometheus server URL
Address: prometheusURL, // Replace with your Prometheus server URL
})
if err != nil {
fmt.Printf("Error creating Prometheus client: %s\n", err)
Expand Down

0 comments on commit d8cf73f

Please sign in to comment.