Skip to content
Snippets Groups Projects
Commit 3cbf14c2 authored by Dan Lorenc's avatar Dan Lorenc
Browse files

Add prometheus /metrics endpoint.

This just exposes the default go metrics for now. We can use middleware to expose
more custom metrics for our API.
parent 38af2455
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@ package app
import (
"flag"
"net/http"
"github.com/go-openapi/loads"
"github.com/projectrekor/rekor/pkg/api"
......@@ -29,6 +30,7 @@ import (
rpm_v001 "github.com/projectrekor/rekor/pkg/types/rpm/v0.0.1"
"github.com/projectrekor/rekor/pkg/generated/restapi"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
......@@ -75,6 +77,12 @@ var serveCmd = &cobra.Command{
api.ConfigureAPI()
server.ConfigureAPI()
http.Handle("/metrics", promhttp.Handler())
go func() {
_ = http.ListenAndServe(":2112", nil)
}()
if err := server.Serve(); err != nil {
log.Logger.Fatal(err)
}
......
......@@ -44,3 +44,14 @@ Install nginx-ingress with: kubectl apply -f nginx.yaml
This was taken from https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.43.0/deploy/static/provider/cloud/deploy.yaml
Local modification was to scale replicas to 3.
Install nginx-ingress with: kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.43.0/deploy/static/provider/cloud/deploy.yaml
## Prometheus
Installed Prometheus Chart with:
```
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo add kube-state-metrics https://kubernetes.github.io/kube-state-metrics
helm install prometheus prometheus-community/prometheus --namespace=prometheus
```
server:
sidecarContainers:
sidecar:
image: gcr.io/stackdriver-prometheus/stackdriver-prometheus-sidecar:0.8.2
imagePullPolicy: Always
args:
- "--stackdriver.project-id=project-rekor"
- "--prometheus.wal-directory=/data/wal"
- "--stackdriver.kubernetes.location=us-central1"
- "--stackdriver.kubernetes.cluster-name=rekor-dev"
ports:
- name: sidecar
containerPort: 9091
volumeMounts:
- name: storage-volume
mountPath: /data
......@@ -13,12 +13,17 @@ spec:
metadata:
labels:
app: rekor-server
annotations:
prometheus.io/scrape: "true"
prometheus.io/path: /metrics
prometheus.io/port: "2112"
spec:
containers:
- name: rekor-server
image: ko://github.com/projectrekor/rekor/cmd/server
ports:
- containerPort: 3000
- containerPort: 2112 # metrics
args: [
"serve",
"--trillian_log_server.address=trillian-server",
......
......@@ -67,6 +67,7 @@ services:
restart: always # keep the server running
ports:
- "3000:3000"
- "2112:2112"
depends_on:
- mysql
- redis-server
......
......@@ -21,7 +21,6 @@ require (
github.com/go-openapi/validate v0.20.1
github.com/golang/protobuf v1.4.3
github.com/google/certificate-transparency-go v1.1.0 // indirect
github.com/google/go-cmp v0.5.2
github.com/google/rpmpack v0.0.0-20210107155803-d6befbf05148
github.com/google/trillian v1.3.10
github.com/jedisct1/go-minisign v0.0.0-20210106175330-e54e81d562c7
......@@ -30,6 +29,7 @@ require (
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/mapstructure v1.4.1
github.com/pelletier/go-toml v1.8.1 // indirect
github.com/prometheus/client_golang v1.9.0
github.com/rs/cors v1.7.0
github.com/spf13/afero v1.5.1 // indirect
github.com/spf13/cast v1.3.1 // indirect
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment