Compare commits

...

2 Commits

Author SHA1 Message Date
Pim van Pelt
fa6ebe4ba5 Reduce interval to 25min, as it is published every 45min 2026-03-24 20:56:52 +01:00
Pim van Pelt
770bfe9806 Add a systemd unit file + default with flags 2026-03-24 20:37:29 +01:00
4 changed files with 66 additions and 6 deletions

View File

@@ -47,6 +47,35 @@ scrape_configs:
- targets: ['localhost:9781']
```
## systemd
A unit file and defaults file are included.
```sh
# install binary
go build -o /usr/local/bin/ctlog-uptime-exporter .
# install defaults (edit to taste)
cp ctlog-uptime-exporter.default /etc/default/ctlog-uptime-exporter
# install and start the service
cp ctlog-uptime-exporter.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable --now ctlog-uptime-exporter
```
Runtime flags are controlled via the `ARGS` variable in `/etc/default/ctlog-uptime-exporter`.
## Grafana dashboard
`dashboard.json` can be imported directly into Grafana (Dashboards -> Import).
It expects a Prometheus datasource and provides:
- Summary stats: number of logs, endpoint types, average uptime, degraded count, fetch status, last fetch time
- Variable selectors for Log URL and Endpoint (both multi-select with All)
- Time series panel showing the rolling 24h uptime ratio over the chosen time range
- Table of the top N least-available log/endpoint pairs (N is selectable: 5, 10, 25, 50)
## License
Apache 2.0 - see [LICENSE](LICENSE).

View File

@@ -0,0 +1,9 @@
# Command-line arguments for ctlog-uptime-exporter.
# Install this file as /etc/default/ctlog-uptime-exporter.
#
# -listen address to listen on (default: :9781)
# -url URL of the uptime CSV (default: https://www.gstatic.com/ct/compliance/endpoint_uptime_24h.csv)
# -interval how often to fetch the CSV (default: 12h)
# -jitter maximum +/-jitter on the interval (default: 5m)
ARGS='-listen :9781 -url https://www.gstatic.com/ct/compliance/endpoint_uptime_24h.csv -interval 12h -jitter 5m'

View File

@@ -0,0 +1,20 @@
[Unit]
Description=CT Log Uptime Prometheus Exporter
Documentation=https://git.ipng.ch/certificate-transparency/ctlog-uptime-exporter
After=network-online.target
Wants=network-online.target
[Service]
EnvironmentFile=/etc/default/ctlog-uptime-exporter
ExecStart=/usr/local/bin/ctlog-uptime-exporter $ARGS
Restart=on-failure
RestartSec=5s
DynamicUser=yes
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
CapabilityBoundingSet=
[Install]
WantedBy=multi-user.target

14
main.go
View File

@@ -16,7 +16,6 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
)
type exporter struct {
mu sync.RWMutex
uptime *prometheus.GaugeVec
@@ -60,7 +59,10 @@ func (e *exporter) fetch(csvURL string) error {
}
// collect new values before updating metrics
type row struct{ logURL, endpoint string; ratio float64 }
type row struct {
logURL, endpoint string
ratio float64
}
var rows []row
for {
rec, err := r.Read()
@@ -113,10 +115,10 @@ func (e *exporter) run(csvURL string, interval, jitter time.Duration) {
}
func main() {
addr := flag.String("listen", ":9781", "address to listen on")
csvURL := flag.String("url", "https://www.gstatic.com/ct/compliance/endpoint_uptime_24h.csv", "URL of the uptime CSV")
interval := flag.Duration("interval", 12*time.Hour, "how often to fetch the CSV")
jitter := flag.Duration("jitter", 5*time.Minute, "maximum +/-jitter applied to the fetch interval")
addr := flag.String("listen", ":9781", "address to listen on")
csvURL := flag.String("url", "https://www.gstatic.com/ct/compliance/endpoint_uptime_24h.csv", "URL of the uptime CSV")
interval := flag.Duration("interval", 25*time.Minute, "how often to fetch the CSV")
jitter := flag.Duration("jitter", 5*time.Minute, "maximum +/-jitter applied to the fetch interval")
flag.Parse()
reg := prometheus.NewRegistry()