Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[+] show stats for vts shared memory #92

Merged
merged 1 commit into from
Nov 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions nginx_vts_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ type NginxVts struct {
Handled uint64 `json:"handled"`
Requests uint64 `json:"requests"`
} `json:"connections"`
SharedZones struct {
Name string `json:"name"`
MaxSize uint64 `json:"maxSize"`
UsedSize uint64 `json:"usedSize"`
UsedNode uint64 `json:"usedNode"`
} `json:"sharedZones"`
ServerZones map[string]Server `json:"serverZones"`
UpstreamZones map[string][]Upstream `json:"upstreamZones"`
FilterZones map[string]map[string]Upstream `json:"filterZones"`
Expand Down Expand Up @@ -185,6 +191,7 @@ func NewExporter(uri string) *Exporter {
"bytes": newServerMetric("bytes", "request/response bytes", []string{"host", "direction"}),
"cache": newServerMetric("cache", "cache counter", []string{"host", "status"}),
"requestMsec": newServerMetric("requestMsec", "average of request processing times in milliseconds", []string{"host"}),
"sharedzones": newServerMetric("sharedzones", "vts module shared memory metrics", []string{"name", "memstat"}),
},
upstreamMetrics: map[string]*prometheus.Desc{
"requests": newUpstreamMetric("requests", "requests counter", []string{"upstream", "code", "backend"}),
Expand Down Expand Up @@ -254,6 +261,11 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
ch <- prometheus.MustNewConstMetric(e.serverMetrics["connections"], prometheus.GaugeValue, float64(nginxVtx.Connections.Handled), "handled")
ch <- prometheus.MustNewConstMetric(e.serverMetrics["connections"], prometheus.GaugeValue, float64(nginxVtx.Connections.Requests), "requests")

// sharedzones
ch <- prometheus.MustNewConstMetric(e.serverMetrics["sharedzones"], prometheus.GaugeValue, float64(nginxVtx.SharedZones.MaxSize), nginxVtx.SharedZones.Name, "maxsize")
ch <- prometheus.MustNewConstMetric(e.serverMetrics["sharedzones"], prometheus.GaugeValue, float64(nginxVtx.SharedZones.UsedSize), nginxVtx.SharedZones.Name, "usedsize")
ch <- prometheus.MustNewConstMetric(e.serverMetrics["sharedzones"], prometheus.GaugeValue, float64(nginxVtx.SharedZones.UsedNode), nginxVtx.SharedZones.Name, "usednode")

// ServerZones
for host, s := range nginxVtx.ServerZones {
ch <- prometheus.MustNewConstMetric(e.serverMetrics["requests"], prometheus.CounterValue, float64(s.RequestCounter), host, "total")
Expand Down