| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | package traefik |
| 4 | |
| 5 | import ( |
| 6 | "fmt" |
| 7 | |
| 8 | "github.com/netdata/netdata/go/plugins/plugin/framework/collectorapi" |
| 9 | ) |
| 10 | |
| 11 | var chartTmplEntrypointRequests = collectorapi.Chart{ |
| 12 | ID: "entrypoint_requests_%s_%s", |
| 13 | Title: "Processed HTTP requests on <code>%s</code> entrypoint (protocol <code>%s</code>)", |
| 14 | Units: "requests/s", |
| 15 | Fam: "entrypoint %s %s", |
| 16 | Ctx: "traefik.entrypoint_requests", |
| 17 | Type: collectorapi.Stacked, |
| 18 | Dims: collectorapi.Dims{ |
| 19 | {ID: prefixEntrypointRequests + "%s_%s_1xx", Name: "1xx", Algo: collectorapi.Incremental}, |
| 20 | {ID: prefixEntrypointRequests + "%s_%s_2xx", Name: "2xx", Algo: collectorapi.Incremental}, |
| 21 | {ID: prefixEntrypointRequests + "%s_%s_3xx", Name: "3xx", Algo: collectorapi.Incremental}, |
| 22 | {ID: prefixEntrypointRequests + "%s_%s_4xx", Name: "4xx", Algo: collectorapi.Incremental}, |
| 23 | {ID: prefixEntrypointRequests + "%s_%s_5xx", Name: "5xx", Algo: collectorapi.Incremental}, |
| 24 | }, |
| 25 | } |
| 26 | |
| 27 | var chartTmplEntrypointRequestDuration = collectorapi.Chart{ |
| 28 | ID: "entrypoint_request_duration_%s_%s", |
| 29 | Title: "Average HTTP request processing time on <code>%s</code> entrypoint (protocol <code>%s</code>)", |
| 30 | Units: "milliseconds", |
| 31 | Fam: "entrypoint %s %s", |
| 32 | Ctx: "traefik.entrypoint_request_duration_average", |
| 33 | Type: collectorapi.Stacked, |
| 34 | Dims: collectorapi.Dims{ |
| 35 | {ID: prefixEntrypointReqDurAvg + "%s_%s_1xx", Name: "1xx"}, |
| 36 | {ID: prefixEntrypointReqDurAvg + "%s_%s_2xx", Name: "2xx"}, |
| 37 | {ID: prefixEntrypointReqDurAvg + "%s_%s_3xx", Name: "3xx"}, |
| 38 | {ID: prefixEntrypointReqDurAvg + "%s_%s_4xx", Name: "4xx"}, |
| 39 | {ID: prefixEntrypointReqDurAvg + "%s_%s_5xx", Name: "5xx"}, |
| 40 | }, |
| 41 | } |
| 42 | |
| 43 | var chartTmplEntrypointOpenConnections = collectorapi.Chart{ |
| 44 | ID: "entrypoint_open_connections_%s_%s", |
| 45 | Title: "Open connections on <code>%s</code> entrypoint (protocol <code>%s</code>)", |
| 46 | Units: "connections", |
| 47 | Fam: "entrypoint %s %s", |
| 48 | Ctx: "traefik.entrypoint_open_connections", |
| 49 | Type: collectorapi.Stacked, |
| 50 | } |
| 51 | |
| 52 | func newChartEntrypointRequests(entrypoint, proto string) *collectorapi.Chart { |
| 53 | return newEntrypointChart(chartTmplEntrypointRequests, entrypoint, proto) |
| 54 | } |
| 55 | |
| 56 | func newChartEntrypointRequestDuration(entrypoint, proto string) *collectorapi.Chart { |
| 57 | return newEntrypointChart(chartTmplEntrypointRequestDuration, entrypoint, proto) |
| 58 | } |
| 59 | |
| 60 | func newChartEntrypointOpenConnections(entrypoint, proto string) *collectorapi.Chart { |
| 61 | return newEntrypointChart(chartTmplEntrypointOpenConnections, entrypoint, proto) |
| 62 | } |
| 63 | |
| 64 | func newEntrypointChart(tmpl collectorapi.Chart, entrypoint, proto string) *collectorapi.Chart { |
| 65 | chart := tmpl.Copy() |
| 66 | chart.ID = fmt.Sprintf(chart.ID, entrypoint, proto) |
| 67 | chart.Title = fmt.Sprintf(chart.Title, entrypoint, proto) |
| 68 | chart.Fam = fmt.Sprintf(chart.Fam, entrypoint, proto) |
| 69 | for _, d := range chart.Dims { |
| 70 | d.ID = fmt.Sprintf(d.ID, entrypoint, proto) |
| 71 | } |
| 72 | return chart |
| 73 | } |