-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from metal-stack/initial
initial version
- Loading branch information
Showing
16 changed files
with
2,051 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name-template: 'v$RESOLVED_VERSION' | ||
tag-template: 'v$RESOLVED_VERSION' | ||
|
||
template: | | ||
## General Changes | ||
$CHANGES | ||
categories: | ||
- title: '🚀 Features' | ||
labels: | ||
- 'feature' | ||
- 'enhancement' | ||
- title: '🐛 Bug Fixes' | ||
labels: | ||
- 'fix' | ||
- 'bugfix' | ||
- 'bug' | ||
|
||
version-resolver: | ||
major: | ||
labels: | ||
- 'major' | ||
minor: | ||
labels: | ||
- 'minor' | ||
patch: | ||
labels: | ||
- 'patch' | ||
default: patch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Build latest image | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Go 1.18 | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.18.x' | ||
|
||
- name: Docker Login | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ${{ secrets.DOCKER_REGISTRY }} | ||
username: ${{ secrets.DOCKER_REGISTRY_USER }} | ||
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | ||
|
||
- name: Lint | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
version: v1.45.0 | ||
args: -p bugs -p unused --timeout=3m | ||
|
||
- name: Build Docker image | ||
run: | | ||
docker build -t ghcr.io/metal-stack/metal-metrics-exporter . | ||
- name: Push Docker image | ||
run: | | ||
docker push ghcr.io/metal-stack/metal-metrics-exporter | ||
- uses: release-drafter/release-drafter@v5 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Build image from pull request | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Go 1.18 | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.18.x' | ||
|
||
- name: Figure out if running fork PR | ||
id: fork | ||
run: '["${{ secrets.DOCKER_REGISTRY_TOKEN }}" == ""] && echo "::set-output name=is_fork_pr::true" || echo "::set-output name=is_fork_pr::false"' | ||
|
||
- name: Docker Login | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ${{ secrets.DOCKER_REGISTRY }} | ||
username: ${{ secrets.DOCKER_REGISTRY_USER }} | ||
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | ||
if: steps.fork.outputs.is_fork_pr == 'false' | ||
|
||
- name: Lint | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
version: v1.45.0 | ||
args: -p bugs -p unused --timeout=3m | ||
|
||
- name: Build Docker image | ||
run: | | ||
docker build -t ghcr.io/metal-stack/metal-metrics-exporter:pr-${GITHUB_HEAD_REF##*/} . | ||
- name: Push Docker image | ||
run: | | ||
# pull request images are prefixed with 'pr' to prevent them from overriding released images | ||
docker push ghcr.io/metal-stack/metal-metrics-exporter:pr-${GITHUB_HEAD_REF##*/} | ||
if: steps.fork.outputs.is_fork_pr == 'false' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Build image from release tag | ||
|
||
on: | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Go 1.18 | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.18.x' | ||
|
||
- name: Docker Login | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ${{ secrets.DOCKER_REGISTRY }} | ||
username: ${{ secrets.DOCKER_REGISTRY_USER }} | ||
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | ||
|
||
- name: Lint | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
version: v1.45.0 | ||
args: -p bugs -p unused --timeout=3m | ||
|
||
- name: Build and push Docker image | ||
run: | | ||
docker build -t ghcr.io/metal-stack/metal-api:${GITHUB_REF##*/} . | ||
docker push ghcr.io/metal-stack/metal-api:${GITHUB_REF##*/} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
FROM golang:1.18-alpine as builder | ||
RUN apk add make binutils | ||
COPY / /work | ||
WORKDIR /work | ||
RUN make metal-metrics-exporter | ||
|
||
FROM alpine:3.15 | ||
COPY --from=builder /work/bin/metal-metrics-exporter /metal-metrics-exporter | ||
USER root | ||
ENTRYPOINT ["/metal-metrics-exporter"] | ||
|
||
EXPOSE 9080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
GO111MODULE := on | ||
DOCKER_TAG := $(or ${GIT_TAG_NAME}, latest) | ||
|
||
all: metal-metrics-exporter | ||
|
||
.PHONY: metal-metrics-exporter | ||
metal-metrics-exporter: | ||
go build -o bin/metal-metrics-exporter *.go | ||
strip bin/metal-metrics-exporter | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f bin/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# metal-metrics-exporter | ||
|
||
A simple exporter for metal-api metrics. | ||
|
||
## sample output | ||
|
||
```text | ||
# HELP metal_image_used_total The total number of machines using a image | ||
# TYPE metal_image_used_total gauge | ||
metal_image_used_total{classification="preview",created="1588078965",expirationDate="1598533365",features="firewall",imageID="firewall-ubuntu-2.0.20200331",name="Firewall 2 Ubuntu 20200331"} 2 | ||
# HELP metal_network_info Shows available prefixes in a network | ||
# TYPE metal_network_info gauge | ||
metal_network_info{description="",destPrefixes="",isPrivateSuper="false",isUnderlay="false",name="ausfalltest",networkId="020966ab-18da-40d6-ba69-fea8d60e6074",parentNetworkID="tenant-super-network-nbg-w8101",partition="nbg-w8101",prefixes="10.91.112.0/22",projectId="c77daafe-58f8-44df-82eb-6ef631cee3c9",useNat="false",vrf="454"} 1 | ||
# HELP metal_network_ip_available The total number of available IPs of the network | ||
# TYPE metal_network_ip_available gauge | ||
metal_network_ip_available{networkId="020966ab-18da-40d6-ba69-fea8d60e6074"} 1024 | ||
# HELP metal_network_ip_used The total number of used IPs of the network | ||
# TYPE metal_network_ip_used gauge | ||
metal_network_ip_used{networkId="020966ab-18da-40d6-ba69-fea8d60e6074"} 2 | ||
# HELP metal_network_prefix_available The total number of available prefixes of the network | ||
# TYPE metal_network_prefix_available gauge | ||
metal_network_prefix_available{networkId="020966ab-18da-40d6-ba69-fea8d60e6074"} 256 | ||
# HELP metal_network_prefix_used The total number of used prefixes of the network | ||
# TYPE metal_network_prefix_used gauge | ||
metal_network_prefix_used{networkId="020966ab-18da-40d6-ba69-fea8d60e6074"} 0 | ||
# HELP metal_partition_capacity_allocated The capacity of allocated machines in the partition | ||
# TYPE metal_partition_capacity_allocated gauge | ||
metal_partition_capacity_allocated{partition="fel-wps101",size="c1-xlarge-x86"} 148 | ||
# HELP metal_partition_capacity_faulty The capacity of faulty machines in the partition | ||
# TYPE metal_partition_capacity_faulty gauge | ||
metal_partition_capacity_faulty{partition="fel-wps101",size="c1-xlarge-x86"} 2 | ||
# HELP metal_partition_capacity_free The capacity of free machines in the partition | ||
# TYPE metal_partition_capacity_free gauge | ||
metal_partition_capacity_free{partition="fel-wps101",size="c1-xlarge-x86"} 5 | ||
# HELP metal_partition_capacity_total The total capacity of machines in the partition | ||
# TYPE metal_partition_capacity_total gauge | ||
metal_partition_capacity_total{partition="fel-wps101",size="c1-xlarge-x86"} 159 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: metal-metrics-exporter | ||
labels: | ||
app: metal-metrics-exporter | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: metal-metrics-exporter | ||
template: | ||
metadata: | ||
labels: | ||
app: metal-metrics-exporter | ||
spec: | ||
securityContext: | ||
runAsUser: 999 | ||
containers: | ||
- name: metal-metrics-exporter | ||
command: | ||
- /metal-metrics-exporter | ||
args: | ||
- start | ||
image: ghcr.io/metal-stack/metal-metrics-exporter:latest | ||
ports: | ||
- containerPort: 9080 | ||
name: metrics | ||
env: | ||
- name: METAL_API_URL | ||
valueFrom: | ||
secretKeyRef: | ||
name: metal-metrics-exporter-config | ||
key: url | ||
- name: METAL_API_HMAC | ||
valueFrom: | ||
secretKeyRef: | ||
name: metal-metrics-exporter-config | ||
key: hmac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: metal-metrics-exporter-config | ||
type: Opaque | ||
stringData: | ||
url: "https://api.example.com/metal" | ||
hmac: "XXXX" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: metal-metrics-exporter | ||
labels: | ||
app: metal-metrics-exporter | ||
spec: | ||
ports: | ||
- name: metrics | ||
port: 9080 | ||
targetPort: metrics | ||
selector: | ||
app: metal-metrics-exporter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: monitoring.coreos.com/v1 | ||
kind: ServiceMonitor | ||
metadata: | ||
labels: | ||
release: prometheus | ||
name: metal-metrics-exporter | ||
spec: | ||
endpoints: | ||
- path: /metrics | ||
port: metrics | ||
interval: 60s | ||
scrapeTimeout: 30s | ||
selector: | ||
matchLabels: | ||
app: metal-metrics-exporter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
module github.com/metal-stack/metal-metrics-exporter | ||
|
||
go 1.18 | ||
|
||
require ( | ||
github.com/metal-stack/metal-go v0.16.5 | ||
github.com/prometheus/client_golang v1.12.1 | ||
k8s.io/klog/v2 v2.60.1 | ||
) | ||
|
||
require ( | ||
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect | ||
github.com/beorn7/perks v1.0.1 // indirect | ||
github.com/cespare/xxhash/v2 v2.1.2 // indirect | ||
github.com/coreos/go-oidc/v3 v3.1.0 // indirect | ||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect | ||
github.com/go-logr/logr v1.2.3 // indirect | ||
github.com/go-openapi/analysis v0.21.3 // indirect | ||
github.com/go-openapi/errors v0.20.2 // indirect | ||
github.com/go-openapi/jsonpointer v0.19.5 // indirect | ||
github.com/go-openapi/jsonreference v0.20.0 // indirect | ||
github.com/go-openapi/loads v0.21.1 // indirect | ||
github.com/go-openapi/runtime v0.23.3 // indirect | ||
github.com/go-openapi/spec v0.20.5 // indirect | ||
github.com/go-openapi/strfmt v0.21.2 // indirect | ||
github.com/go-openapi/swag v0.21.1 // indirect | ||
github.com/go-openapi/validate v0.21.0 // indirect | ||
github.com/go-stack/stack v1.8.1 // indirect | ||
github.com/goccy/go-json v0.9.6 // indirect | ||
github.com/golang-jwt/jwt/v4 v4.4.1 // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/google/uuid v1.3.0 // indirect | ||
github.com/gorilla/mux v1.8.0 // indirect | ||
github.com/josharian/intern v1.0.0 // indirect | ||
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect | ||
github.com/lestrrat-go/blackmagic v1.0.1 // indirect | ||
github.com/lestrrat-go/httpcc v1.0.1 // indirect | ||
github.com/lestrrat-go/iter v1.0.2 // indirect | ||
github.com/lestrrat-go/jwx v1.2.23 // indirect | ||
github.com/lestrrat-go/option v1.0.0 // indirect | ||
github.com/mailru/easyjson v0.7.7 // indirect | ||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect | ||
github.com/metal-stack/masterdata-api v0.8.11 // indirect | ||
github.com/metal-stack/metal-lib v0.9.0 // indirect | ||
github.com/metal-stack/security v0.6.4 // indirect | ||
github.com/mitchellh/mapstructure v1.5.0 // indirect | ||
github.com/oklog/ulid v1.3.1 // indirect | ||
github.com/opentracing/opentracing-go v1.2.0 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/prometheus/client_model v0.2.0 // indirect | ||
github.com/prometheus/common v0.34.0 // indirect | ||
github.com/prometheus/procfs v0.7.3 // indirect | ||
go.mongodb.org/mongo-driver v1.9.0 // indirect | ||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect | ||
golang.org/x/net v0.0.0-20220420153159-1850ba15e1be // indirect | ||
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect | ||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect | ||
google.golang.org/appengine v1.6.7 // indirect | ||
google.golang.org/protobuf v1.28.0 // indirect | ||
gopkg.in/square/go-jose.v2 v2.6.0 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
) |
Oops, something went wrong.