Skip to content
This repository has been archived by the owner on Sep 19, 2018. It is now read-only.

Commit

Permalink
Merge pull request #16 from utilitywarehouse/kubernetes-io-metrics
Browse files Browse the repository at this point in the history
Introduce metric on errors from kube api calls
  • Loading branch information
ffilippopoulos committed Mar 27, 2018
2 parents 7590c98 + a1fc7d1 commit dd711c3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN apk add --no-cache \
&& apk add --no-cache --virtual=.builddeps \
-X http://dl-cdn.alpinelinux.org/alpine/edge/community \
git \
go \
go=1.8.4-r0 \
musl-dev \
&& export GOPATH=/go \
&& cd $GOPATH/src/${IMPORT_PATH} \
Expand Down
22 changes: 22 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/utilitywarehouse/go-operational/op"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/tools/clientcmd"
)

Expand Down Expand Up @@ -79,12 +80,33 @@ var (
Help: "number of route53 updates rejected",
},
)

// ListWatch runs every 30 seconds (approx). That means that we can allow up to 9
// errors on a per 5m rate of the following metric otherwise every call to kube
// api is failing (so rate > 0.03 => evry call to api fails)
metricKubernetesIOError = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: "ingress53",
Subsystem: "kubernetes",
Name: "io_error",
Help: "number of errors occured while talking to kube api",
},
)
)

// UpdateKubernetesIOErrorCount: to keep count of errors while talking to kube api
func UpdateKubernetesIOErrorCount(err error) {
metricKubernetesIOError.Inc()
}

func main() {
prometheus.MustRegister(metricUpdatesApplied)
prometheus.MustRegister(metricUpdatesReceived)
prometheus.MustRegister(metricUpdatesRejected)
prometheus.MustRegister(metricKubernetesIOError)

// Register KubernetesIO Error Handling
utilruntime.ErrorHandlers = append(utilruntime.ErrorHandlers, UpdateKubernetesIOErrorCount)

flag.Var(&targets, "target", "List of endpoints (ELB) targets to map ingress records to")
flag.Parse()
Expand Down

0 comments on commit dd711c3

Please sign in to comment.