This example app serves as an example of how one can easily instrument HTTP handlers with Prometheus metrics. It uses the Prometheus go client to create a new Prometheus registry.
Usage is simple, on any request to / the request will result in a 200 response code.
This increments the counter for this response code.
Similarly the /err endpoint will result in a 404 response code, therefore increments that respective counter.
Duration metrics are also exposed for any request to /.
FROM golang:alpine AS builder
RUN apk update && apk add --no-cache git
COPY src $GOPATH/src/prometheus-app-example
WORKDIR $GOPATH/src/prometheus-app-example
RUN go get -d -v
RUN go build -o /tmp/app-example *.go
FROM alpine
RUN addgroup -S appgroup && adduser -S appuser -G appgroup && mkdir -p /app
COPY --from=builder /tmp/app-example /app
RUN chmod a+rx /app/app-example
USER appuser
WORKDIR /app
ENV LISTENING_PORT 8080
CMD ["./app-example"]
Content type
Image
Digest
Size
-
Last updated
about 6 years ago
docker pull hermedia/prometheus-app-example:1.0