Export metrics to Prometheus
Configure Prometheus or Grafana Alloy to scrape metrics from Scanopy.
Prerequisites
- Scanopy server running
- Prometheus 2.47+ or Grafana Alloy installed
Configure Scanopy
First, generate a metrics token using openssl rand -base64 or similar.
Set the metrics token in your Scanopy environment:
SCANOPY_METRICS_TOKEN=your-secure-token-hereTo restrict access to specific IPs or networks:
SCANOPY_EXTERNAL_SERVICE_PROMETHEUS_ALLOWED_IPS=192.168.1.0/24,10.0.0.1Restart Scanopy after changing environment variables.
Configure Prometheus
Add a scrape job to your prometheus.yml:
scrape_configs:
- job_name: 'scanopy'
metrics_path: /api/metrics
static_configs:
- targets: ['scanopy.example.com:60072']
authorization:
type: Bearer
credentials: your-secure-token-here
http_headers:
X-Service-Name:
values: [prometheus]Configure Grafana Alloy
Add a prometheus.scrape component to your Alloy configuration:
prometheus.scrape "scanopy" {
targets = [{
__address__ = "scanopy.example.com:60072",
}]
forward_to = [prometheus.remote_write.default.receiver]
metrics_path = "/api/metrics"
authorization {
type = "Bearer"
credentials = "your-secure-token-here"
}
http_headers = {
"X-Service-Name" = "prometheus",
}
}