timoschlueter / nightscout-librelink-up

Script written in TypeScript that uploads CGM readings from LibreLink Up to Nightscout.
MIT License
192 stars 246 forks source link

Export librelink values as Prometheus metrics #89

Closed solsson closed 1 year ago

solsson commented 1 year ago

Thank's for a great project.

The PR is not meant to be merged, due to modified github workflow. Filed in case anyone else is looking for Freestyle Libre to Prometheus. There's docker images at https://github.com/users/solsson/packages/container/package/nightscout-librelink-up. I could also make a code-only PR if someone is interested in a merge.

Running this in Kubernetes with the following yaml

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: librelink-exporter
  labels:
    app: librelink-exporter
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 1
  selector:
    matchLabels:
      app: librelink-exporter
  template:
    metadata:
      labels:
        app: librelink-exporter
    spec:
      containers:
      - name: app
        image: ghcr.io/solsson/nightscout-librelink-up
        env:
        # kubectl create secret generic librelink-auth --from-literal=username= --from-literal=password=
        - name: LINK_UP_USERNAME
          valueFrom:
            secretKeyRef:
              name: librelink-auth
              key: username
        - name: LINK_UP_PASSWORD
          valueFrom:
            secretKeyRef:
              name: librelink-auth
              key: password
        - name: LINK_UP_TIME_INTERVAL
          value: "1"
        ports:
        - containerPort: 8080
          name: http
---
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
  name: librelink-exporter
  labels:
    [your prometheus matcher]
spec:
  jobLabel: app
  namespaceSelector:
    any: false
  selector:
    matchLabels:
      app: librelink-exporter
  podMetricsEndpoints:
  - port: http
    path: /metrics
timoschlueter commented 1 year ago

This is awesome! Could you make a PR with just the code chances? This would be a great addition to the plug-in and makes integration in all kinds of monitoring solutions possible :)