Compare commits
2 Commits
699c3680cd
...
fa6ebe4ba5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa6ebe4ba5 | ||
|
|
770bfe9806 |
29
README.md
29
README.md
@@ -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).
|
||||
|
||||
9
ctlog-uptime-exporter.default
Normal file
9
ctlog-uptime-exporter.default
Normal 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'
|
||||
20
ctlog-uptime-exporter.service
Normal file
20
ctlog-uptime-exporter.service
Normal 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
14
main.go
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user