1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-01-08 10:45:04 +02:00

Add IMGPROXY_PROMETHEUS_NAMESPACE config (#405)

* Add IMGPROXY_PROMETHEUS_NAMESPACE config

* Add documentations about IMGPROXY_PROMETHEUS_NAMESPACE

Co-authored-by: Alexey Remizov <alexey.remizov@sport24.ru>
This commit is contained in:
Alexey Remizov 2020-06-10 16:11:14 +03:00 committed by GitHub
parent ebc7d0e644
commit b783e8bebf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 24 deletions

View File

@ -231,7 +231,8 @@ type config struct {
NewRelicAppName string NewRelicAppName string
NewRelicKey string NewRelicKey string
PrometheusBind string PrometheusBind string
PrometheusNamespace string
BugsnagKey string BugsnagKey string
BugsnagStage string BugsnagStage string
@ -389,6 +390,7 @@ func configure() error {
strEnvConfig(&conf.NewRelicKey, "IMGPROXY_NEW_RELIC_KEY") strEnvConfig(&conf.NewRelicKey, "IMGPROXY_NEW_RELIC_KEY")
strEnvConfig(&conf.PrometheusBind, "IMGPROXY_PROMETHEUS_BIND") strEnvConfig(&conf.PrometheusBind, "IMGPROXY_PROMETHEUS_BIND")
strEnvConfig(&conf.PrometheusNamespace, "IMGPROXY_PROMETHEUS_NAMESPACE")
strEnvConfig(&conf.BugsnagKey, "IMGPROXY_BUGSNAG_KEY") strEnvConfig(&conf.BugsnagKey, "IMGPROXY_BUGSNAG_KEY")
strEnvConfig(&conf.BugsnagStage, "IMGPROXY_BUGSNAG_STAGE") strEnvConfig(&conf.BugsnagStage, "IMGPROXY_BUGSNAG_STAGE")

View File

@ -3,7 +3,9 @@
imgproxy can collect its metrics for Prometheus. To use this feature, do the following: imgproxy can collect its metrics for Prometheus. To use this feature, do the following:
1. Set `IMGPROXY_PROMETHEUS_BIND` environment variable. Note that you can't bind the main server and Prometheus to the same port; 1. Set `IMGPROXY_PROMETHEUS_BIND` environment variable. Note that you can't bind the main server and Prometheus to the same port;
2. Collect the metrics from any path on the specified binding. 2. Set `IMGPROXY_PROMETHEUS_NAMESPACE` to prepend prefix to the names of metrics.
I.e. with `IMGPROXY_PROMETHEUS_NAMESPACE=imgproxy` names will look like `imgproxy_requests_total`.
3. Collect the metrics from any path on the specified binding.
imgproxy will collect the following metrics: imgproxy will collect the following metrics:

View File

@ -32,58 +32,69 @@ func initPrometheus() {
} }
prometheusRequestsTotal = prometheus.NewCounter(prometheus.CounterOpts{ prometheusRequestsTotal = prometheus.NewCounter(prometheus.CounterOpts{
Name: "requests_total", Namespace: conf.PrometheusNamespace,
Help: "A counter of the total number of HTTP requests imgproxy processed.", Name: "requests_total",
Help: "A counter of the total number of HTTP requests imgproxy processed.",
}) })
prometheusErrorsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{ prometheusErrorsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "errors_total", Namespace: conf.PrometheusNamespace,
Help: "A counter of the occurred errors separated by type.", Name: "errors_total",
Help: "A counter of the occurred errors separated by type.",
}, []string{"type"}) }, []string{"type"})
prometheusRequestDuration = prometheus.NewHistogram(prometheus.HistogramOpts{ prometheusRequestDuration = prometheus.NewHistogram(prometheus.HistogramOpts{
Name: "request_duration_seconds", Namespace: conf.PrometheusNamespace,
Help: "A histogram of the response latency.", Name: "request_duration_seconds",
Help: "A histogram of the response latency.",
}) })
prometheusDownloadDuration = prometheus.NewHistogram(prometheus.HistogramOpts{ prometheusDownloadDuration = prometheus.NewHistogram(prometheus.HistogramOpts{
Name: "download_duration_seconds", Namespace: conf.PrometheusNamespace,
Help: "A histogram of the source image downloading latency.", Name: "download_duration_seconds",
Help: "A histogram of the source image downloading latency.",
}) })
prometheusProcessingDuration = prometheus.NewHistogram(prometheus.HistogramOpts{ prometheusProcessingDuration = prometheus.NewHistogram(prometheus.HistogramOpts{
Name: "processing_duration_seconds", Namespace: conf.PrometheusNamespace,
Help: "A histogram of the image processing latency.", Name: "processing_duration_seconds",
Help: "A histogram of the image processing latency.",
}) })
prometheusBufferSize = prometheus.NewHistogramVec(prometheus.HistogramOpts{ prometheusBufferSize = prometheus.NewHistogramVec(prometheus.HistogramOpts{
Name: "buffer_size_bytes", Namespace: conf.PrometheusNamespace,
Help: "A histogram of the buffer size in bytes.", Name: "buffer_size_bytes",
Help: "A histogram of the buffer size in bytes.",
}, []string{"type"}) }, []string{"type"})
prometheusBufferDefaultSize = prometheus.NewGaugeVec(prometheus.GaugeOpts{ prometheusBufferDefaultSize = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "buffer_default_size_bytes", Namespace: conf.PrometheusNamespace,
Help: "A gauge of the buffer default size in bytes.", Name: "buffer_default_size_bytes",
Help: "A gauge of the buffer default size in bytes.",
}, []string{"type"}) }, []string{"type"})
prometheusBufferMaxSize = prometheus.NewGaugeVec(prometheus.GaugeOpts{ prometheusBufferMaxSize = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "buffer_max_size_bytes", Namespace: conf.PrometheusNamespace,
Help: "A gauge of the buffer max size in bytes.", Name: "buffer_max_size_bytes",
Help: "A gauge of the buffer max size in bytes.",
}, []string{"type"}) }, []string{"type"})
prometheusVipsMemory = prometheus.NewGauge(prometheus.GaugeOpts{ prometheusVipsMemory = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "vips_memory_bytes", Namespace: conf.PrometheusNamespace,
Help: "A gauge of the vips tracked memory usage in bytes.", Name: "vips_memory_bytes",
Help: "A gauge of the vips tracked memory usage in bytes.",
}) })
prometheusVipsMaxMemory = prometheus.NewGauge(prometheus.GaugeOpts{ prometheusVipsMaxMemory = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "vips_max_memory_bytes", Namespace: conf.PrometheusNamespace,
Help: "A gauge of the max vips tracked memory usage in bytes.", Name: "vips_max_memory_bytes",
Help: "A gauge of the max vips tracked memory usage in bytes.",
}) })
prometheusVipsAllocs = prometheus.NewGauge(prometheus.GaugeOpts{ prometheusVipsAllocs = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "vips_allocs", Namespace: conf.PrometheusNamespace,
Help: "A gauge of the number of active vips allocations.", Name: "vips_allocs",
Help: "A gauge of the number of active vips allocations.",
}) })
prometheus.MustRegister( prometheus.MustRegister(