No description
- Go 73%
- Makefile 18%
- Dockerfile 9%
|
|
||
|---|---|---|
| .github | ||
| docs | ||
| pkg | ||
| .gitignore | ||
| .golangci.yaml | ||
| .openapi-config.yaml | ||
| .pre-commit-config.yaml | ||
| config.schema.v1.json | ||
| config.yaml | ||
| Dockerfile | ||
| generator.patch.yaml | ||
| go.mod | ||
| go.sum | ||
| LICENSE.txt | ||
| Makefile | ||
| README.md | ||
| VERSION | ||
Netzservice SWKA exporter for prometheus
Prometheus exporter for Netzservice-SWKA customer accounts.
Setup
- Populate config file, here is an example:
config:
username: myuser
password: mypassword
Note: there is JSON schema for configuration here
Run locally
./exporter
ts=2024-02-25T08:18:50.577Z caller=main.go:83 level=info msg="Starting tuya_smartplug_exporter" version="(version=v1.0.0, branch=main, revision=9d0b7b3)" config=config.yaml
ts=2024-02-25T08:18:50.582Z caller=main.go:98 level=info msg="Configured 1 devices"
ts=2024-02-25T08:18:50.583Z caller=tls_config.go:313 level=info msg="Listening on" address=[::]:9999
ts=2024-02-25T08:18:50.583Z caller=tls_config.go:316 level=info msg="TLS is disabled." http2=false address=[::]:9999
Run using docker
docker run -ti -v $(pwd)/config.yaml:/config.yaml:ro ghcr.io/rkosegi/tuya-smartplug-exporter:v1.1.0
Example output
curl --silent localhost:9999/metrics | grep ^tuya
tuya_smartplug_exporter_build_info{branch="main",goarch="amd64",goos="linux",goversion="go1.26.2",revision="96c611a",tags="unknown",version="v1.1.0"} 1
tuya_smartplug_last_scrape_error 0
tuya_smartplug_current{device="livingroom-1"} 0.093
tuya_smartplug_power{device="livingroom-1"} 8.6
tuya_smartplug_scrape_duration_sum{device="livingroom-1"} 73
tuya_smartplug_scrape_duration_count{device="livingroom-1"} 1
tuya_smartplug_total_scrapes_sum 0.62671565
tuya_smartplug_total_scrapes_count 3
tuya_smartplug_voltage{device="livingroom-1"} 242.9
tuya_smartplug_read_packets_total{device="livingroom-1"} 6
tuya_smartplug_sent_packets_total{device="livingroom-1"} 9
Description of metrics
| Name | Type | Description | Scope |
|---|---|---|---|
tuya_smartplug_last_scrape_error |
Counter |
Indication of overall error during scrape | Global |
tuya_smartplug_scrapes_total |
Summary |
Overall duration and count of scrapes | Global |
tuya_smartplug_exporter_build_info |
Gauge |
Build info | Global |
tuya_smartplug_current |
Gauge |
Electrical current drawn, in Amperes | Device |
tuya_smartplug_power |
Gauge |
Total power used, in Watts | Device |
tuya_smartplug_scrape_duration |
Summary |
Summary of scrape operation | Device |
tuya_smartplug_switch_on |
Gauge |
Whether the plug is switched on (1 for on, 0 for off) | Device |
tuya_smartplug_voltage |
Gauge |
Electrical voltage, in Volts | Device |
tuya_smartplug_read_errors_total |
Counter |
Total number of read errors | Device |
tuya_smartplug_read_packets_total |
Counter |
Total number of read packets | Device |
tuya_smartplug_sent_errors_total |
Counter |
Total number of sent errors | Device |
tuya_smartplug_sent_packets_total |
Counter |
Total number of sent packets | Device |
Install using Helm chart to k8s cluster
First, make sure your values are present in file my-values.yaml, then run
helm repo add rkosegi https://rkosegi.github.io/helm-charts/ --force-update
helm upgrade --install rkosegi/generic-exporter --values my-values.yaml
Sample Grafana dashboard
Acknowledgment
Portion of client code is inspired by @rkosegi implementation in tuya-smartplug-exporter
