Skip to content

Commit

Permalink
Implement rootfs usage metrics (#1)
Browse files Browse the repository at this point in the history
* Implement rootfs usage metrics

* Fix names in metric table
  • Loading branch information
ribbybibby authored Jan 11, 2021
1 parent c80e0e4 commit 427b138
Show file tree
Hide file tree
Showing 7 changed files with 1,022 additions and 1 deletion.
32 changes: 32 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
kind: pipeline
type: kubernetes
name: default

steps:
- name: fetch
image: docker:git
commands:
- git fetch --tags

- name: docker-tag
image: alpine
commands:
- test "${DRONE_BRANCH}" == "master" && echo -n "latest," > .tags || true
- test -n "${DRONE_BRANCH}" && test "${DRONE_BRANCH}" != "master" && echo -n "${DRONE_BRANCH}," > .tags || true
- test -n "${DRONE_TAG}" && echo -n "${DRONE_TAG}," >> .tags || true
- sed -i "s/,$//" .tags

- name: docker-publish
image: plugins/docker
settings:
username:
from_secret: docker_username
password:
from_secret: docker_password
repo: quay.io/utilitywarehouse/kube-summary-exporter
registry: quay.io

trigger:
event:
exclude:
- pull_request
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kube-summary-exporter
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM golang:1.15-alpine AS build
WORKDIR /go/src/github.com/utilitywarehouse/kube-summary-exporter
COPY . /go/src/github.com/utilitywarehouse/kube-summary-exporter
ENV CGO_ENABLED 0
RUN apk --no-cache add git &&\
go get -t ./... &&\
go test ./... &&\
go build -o /kube-summary-exporter .

FROM alpine:3.12
COPY --from=build /kube-summary-exporter /kube-summary-exporter

ENTRYPOINT [ "/kube-summary-exporter"]
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
# kube-stats-exporter
# kube-summary-exporter

[![Build Status](https://drone.prod.merit.uw.systems/api/badges/utilitywarehouse/kube-summary-exporter/status.svg)](https://drone.prod.merit.uw.systems/utilitywarehouse/kube-summary-exporter)

Exports prometheus metrics for the Kubernetes Summary API.

## Usage

Visiting http://localhost:9779/node/example-node will return metrics for the
node 'example-node'.

Here's an example scrape config. This assumes that the exporter is available at `kube-summary-exporter:9779`.

```
- job_name: "kubernetes-summary"
kubernetes_sd_configs:
- role: node
relabel_configs:
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
- source_labels: [__meta_kubernetes_node_name]
regex: (.+)
target_label: __metrics_path__
replacement: /node/${1}
- target_label: __address__
replacement: kube-summary-exporter:9779
```

## Metrics

| Metric | Description | Labels |
| -------------------------------- | ----------------------------------------------------- | -------------------- |
| container_rootfs_inodes_free | Number of available Inodes | pod, namespace, name |
| container_rootfs_inodes | Number of Inodes | pod, namespace, name |
| container_rootfs_inodes_used | Number of used Inodes | pod, namespace, name |
| container_rootfs_available_bytes | Number of bytes that aren't consumed by the container | pod, namespace, name |
| container_rootfs_capacity_bytes | Number of bytes that can be consumed by the container | pod, namespace, name |
| container_rootfs_used_bytes | Number of bytes that are consumed by the container | pod, namespace, name |
17 changes: 17 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module github.com/utilitywarehouse/kube-summary-exporter

go 1.15

require (
github.com/gorilla/mux v1.8.0
github.com/prometheus/client_golang v1.9.0
k8s.io/client-go v0.20.1
k8s.io/kubelet v0.20.1
)

replace (
k8s.io/api => k8s.io/api v0.20.1
k8s.io/apimachinery => k8s.io/apimachinery v0.20.1
k8s.io/client-go => k8s.io/client-go v0.20.1
k8s.io/kubelet => k8s.io/kubelet v0.20.1
)
Loading

0 comments on commit 427b138

Please sign in to comment.