Skip to content

Commit 994b131

Browse files
committed
added ability to change port, updated docs
1 parent 631c00a commit 994b131

11 files changed

+28
-2
lines changed

.github/ISSUE_TEMPLATE/bug-report.md

100644100755
File mode changed.

.github/ISSUE_TEMPLATE/enhancement-request.md

100644100755
File mode changed.

.github/pull_request_template.md

100644100755
File mode changed.

CODE_OF_CONDUCT.md

100644100755
File mode changed.

CONTRIBUTING.md

100644100755
File mode changed.

LICENSE

100644100755
File mode changed.

README.md

100644100755
File mode changed.

grafana/rubrik_dashboard.json

100644100755
File mode changed.

quickstart.md

100644100755
+17
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ docker build -t rubrikinc/prometheus-client -f Dockerfile .
3333

3434
The resulting docker image will be in the local repository on the server.
3535

36+
This docker image is also available on the Docker Hub at [this link](https://hub.docker.com/repository/docker/rubrikinc/rubrik-prometheus-client).
37+
3638
## Using the Prometheus Agent
3739

3840
Ensure that the following environment variables exist, and are defined: `rubrik_cdm_node_ip`, `rubrik_cdm_username`, `rubrik_cdm_password`.
@@ -53,3 +55,18 @@ docker run -d -t -e rubrik_cdm_node_ip=$rubrik_cdm_node_ip \
5355
```
5456

5557
This will map port 8080 inside the container, to port 8080 on the docker host. Metrics will then be browsable via `http://localhost:8080/metrics`.
58+
59+
### Using an alternative HTTP port
60+
61+
In order to use an alternative HTTP port (if default of 8080 is already in use, or using it is not desirable) we can set the below environment variable to override the port:
62+
63+
```bash
64+
export RUBRIK_PROMETHEUS_PORT=9090
65+
```
66+
67+
When the application starts, the log will show the port being used:
68+
69+
```none
70+
2020/10/22 11:21:47 Cluster name: rubrik-1
71+
2020/10/22 11:21:47 Starting on HTTP port 9090
72+
```

src/golang/main.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"log"
1616
"net/http"
1717
"time"
18-
18+
"os"
1919
"github.com/prometheus/client_golang/prometheus/promhttp"
2020
"github.com/rubrikinc/rubrik-client-for-prometheus/src/golang/jobs"
2121
"github.com/rubrikinc/rubrik-client-for-prometheus/src/golang/livemount"
@@ -24,6 +24,14 @@ import (
2424
)
2525

2626
func main() {
27+
// set our Prometheus variables
28+
httpPortEnv, _ := os.LookupEnv("RUBRIK_PROMETHEUS_PORT")
29+
var httpPort string;
30+
if httpPortEnv == "" {
31+
httpPort = "8080"
32+
} else {
33+
httpPort = httpPortEnv
34+
}
2735
rubrik, err := rubrikcdm.ConnectEnv()
2836
if err != nil {
2937
log.Printf("Error from main.go:")
@@ -105,5 +113,6 @@ func main() {
105113
// The Handler function provides a default handler to expose metrics
106114
// via an HTTP server. "/metrics" is the usual endpoint for that.
107115
http.Handle("/metrics", promhttp.Handler())
108-
log.Fatal(http.ListenAndServe(":8080", nil))
116+
log.Printf("Starting on HTTP port "+httpPort)
117+
log.Fatal(http.ListenAndServe(":"+httpPort, nil))
109118
}

src/python/prometheus_client.py

100644100755
File mode changed.

0 commit comments

Comments
 (0)