This repository was archived by the owner on Jul 7, 2022. It is now read-only.
File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change
1
+ .idea
Original file line number Diff line number Diff line change @@ -277,6 +277,13 @@ func main() {
277
277
}
278
278
```
279
279
280
+ Compile and run the server
281
+
282
+ ``` bash
283
+ go build server.go
284
+ ./server.go
285
+ ```
286
+
280
287
We have a simple server which when hit on localhost:8090/ping endpoint sends back pong
281
288
282
289
<p align =" center " >
@@ -322,7 +329,7 @@ The `prometheus.MustRegister` function registers the pingCounter to the default
322
329
To expose the metrics the Go Prometheus client library provides the promhttp package.
323
330
` promhttp.Handler() ` provides a ` http.Handler ` which exposes the metrics registered in the Default Register.
324
331
325
- _ serverWithMetric.go_
332
+ Here is the complete _ serverWithMetric.go_ at this point.
326
333
327
334
``` go
328
335
package main
@@ -356,6 +363,15 @@ func main() {
356
363
}
357
364
```
358
365
366
+ Re-compile the binary
367
+ ``` bash
368
+ go get github.com/prometheus/client_golang/prometheus
369
+ go get github.com/prometheus/client_golang/prometheus/promhttp
370
+ go build server.go
371
+ ./server.go
372
+ ```
373
+
374
+
359
375
Now hit the localhost:8090/ping endpoint a couple of times and sending a request to localhost:8090 will provide the metrics.
360
376
361
377
<p align =" center " >
You can’t perform that action at this time.
0 commit comments