Skip to content

Commit ee8c878

Browse files
committed
Add telemetry catalogs for NGINX OSS and Plus metrics
1 parent bb30122 commit ee8c878

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2112
-937
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ $(RPM_PACKAGE):
110110
include Makefile.tools
111111
include Makefile.containers
112112
include Makefile.packaging
113+
include Makefile.weaver
113114

114115
.PHONY: help clean no-local-changes build lint format unit-test integration-test run dev run-mock-management-grpc-server generate generate-mocks local-apk-package local-deb-package local-rpm-package
115116
help: ## Show help message
@@ -282,7 +283,7 @@ stop-mock-otel-collector-without-nap: ## Stop running mock management plane OTel
282283
@echo "Stopping mock management plane OTel collector without NAP"
283284
AGENT_IMAGE_WITH_NGINX_PLUS=nginx_plus_$(IMAGE_TAG):latest AGENT_IMAGE_WITH_NGINX_OSS=nginx_oss_$(IMAGE_TAG):latest $(CONTAINER_COMPOSE) -f ./test/mock/collector/docker-compose.yaml down
284285

285-
generate: ## Generate golang code
286+
generate: nginx-metadata-gen nginxplus-metadata-gen ## Generate golang code
286287
@echo "🗄️ Generating proto files"
287288
@cd api/grpc && $(GORUN) $(BUF) generate
288289
@echo "🗃️ Generating go files"

Makefile.weaver

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
2+
# https://github.com/open-telemetry/weaver #
3+
# These images are for invoking weaver #
4+
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
5+
6+
# From where to resolve the containers (e.g. "otel/weaver").
7+
CONTAINER_REPOSITORY=docker.io
8+
9+
# Per container overrides for the repository resolution.
10+
WEAVER_CONTAINER_REPOSITORY=$(CONTAINER_REPOSITORY)
11+
SEMCONVGEN_CONTAINER_REPOSITORY=$(CONTAINER_REPOSITORY)
12+
OPA_CONTAINER_REPOSITORY=$(CONTAINER_REPOSITORY)
13+
14+
CHECK_TARGETS=install-tools markdownlint
15+
16+
# Versioned, non-qualified references to containers used in this Makefile.
17+
# These are parsed from dependencies.Dockerfile so dependabot will autoupdate
18+
# the versions of docker files we use.
19+
VERSIONED_WEAVER_CONTAINER_NO_REPO=$(shell cat dependencies.Dockerfile | awk '$$4=="weaver" {print $$2}')
20+
VERSIONED_SEMCONVGEN_CONTAINER_NO_REPO=$(shell cat dependencies.Dockerfile | awk '$$4=="semconvgen" {print $$2}')
21+
VERSIONED_OPA_CONTAINER_NO_REPO=$(shell cat dependencies.Dockerfile | awk '$$4=="opa" {print $$2}')
22+
23+
# Fully qualified references to containers used in this Makefile. These
24+
# include the container repository, so that the build will work with tools
25+
# like "podman" with a default "/etc/containers/registries.conf", where
26+
# a default respository of "docker.io" is not assumed. This is intended to
27+
# eliminate errors from podman such as:
28+
#
29+
# Error: short-name "otel/weaver:v1.2.3" did not resolve to an alias
30+
# and no unqualified-search registries are defined in "/etc/containers/registries.conf"
31+
WEAVER_CONTAINER=$(WEAVER_CONTAINER_REPOSITORY)/$(VERSIONED_WEAVER_CONTAINER_NO_REPO)
32+
SEMCONVGEN_CONTAINER=$(SEMCONVGEN_CONTAINER_REPOSITORY)/$(VERSIONED_SEMCONVGEN_CONTAINER_NO_REPO)
33+
OPA_CONTAINER=$(OPA_CONTAINER_REPOSITORY)/$(VERSIONED_OPA_CONTAINER_NO_REPO)
34+
35+
# Determine if "docker" is actually podman
36+
DOCKER_VERSION_OUTPUT := $(shell docker --version 2>&1)
37+
DOCKER_IS_PODMAN := $(shell echo $(DOCKER_VERSION_OUTPUT) | grep -c podman)
38+
39+
ifeq ($(DOCKER_IS_PODMAN),0)
40+
DOCKER_COMMAND := docker
41+
else
42+
DOCKER_COMMAND := podman
43+
endif
44+
45+
# Debug printing
46+
ifdef DEBUG
47+
$(info Docker version output: $(DOCKER_VERSION_OUTPUT))
48+
$(info Is Docker actually Podman? $(DOCKER_IS_PODMAN))
49+
$(info Using command: $(DOCKER_COMMAND))
50+
endif
51+
52+
DOCKER_RUN=$(DOCKER_COMMAND) run
53+
DOCKER_USER=$(shell id -u):$(shell id -g)
54+
DOCKER_USER_IS_HOST_USER_ARG=-u $(DOCKER_USER)
55+
ifeq ($(DOCKER_COMMAND),podman)
56+
# On podman, additional arguments are needed to make "-u" work
57+
# correctly with the host user ID and host group ID.
58+
#
59+
# Error: OCI runtime error: crun: setgroups: Invalid argument
60+
DOCKER_USER_IS_HOST_USER_ARG=--userns=keep-id -u $(DOCKER_USER)
61+
endif
62+
63+
# Generate attribute registry metadata for mdatagen.
64+
# Example uses:
65+
# make nginxplus-metadata-gen
66+
# make nginx-metadata-gen
67+
.PHONY: %-metadata-gen
68+
%-metadata-gen:
69+
$(DOCKER_RUN) --rm \
70+
$(DOCKER_USER_IS_HOST_USER_ARG) \
71+
--mount 'type=bind,source=$(PWD)/templates,target=/home/weaver/templates,readonly' \
72+
--mount 'type=bind,source=$(PWD)/catalog/$*,target=/home/weaver/source/,readonly' \
73+
--mount 'type=bind,source=$(PWD)/internal/collector,target=/home/weaver/target' \
74+
$(WEAVER_CONTAINER) registry generate \
75+
--registry=/home/weaver/source \
76+
--templates=/home/weaver/templates \
77+
metadata \
78+
/home/weaver/target/$*receiver
79+
cat $(PWD)/internal/collector/$*receiver/*_metadata.yaml > $(PWD)/internal/collector/$*receiver/metadata.yaml
80+
rm $(PWD)/internal/collector/$*receiver/*_metadata.yaml
81+
@echo "🗃️ Generating go files"
82+
@$(GOGEN) $(PWD)/internal/collector/$*receiver/...

catalog/nginx/metrics.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/open-telemetry/weaver/v0.9.2/schemas/semconv.schema.json
2+
groups:
3+
# nginx.http.* metrics
4+
- id: metric.nginx.http.connections
5+
type: metric
6+
unit: "connections"
7+
metric_name: nginx.http.connections
8+
stability: experimental
9+
brief: "The total number of connections, since NGINX was last started or reloaded."
10+
instrument: counter
11+
note: |
12+
Source: HTTP GET `/status`
13+
attributes:
14+
- ref: nginx.connections.outcome
15+
requirement_level: required
16+
17+
- id: metric.nginx.http.connection.count
18+
type: metric
19+
unit: "connections"
20+
metric_name: nginx.http.connection.count
21+
stability: experimental
22+
brief: "The current number of connections."
23+
instrument: gauge
24+
note: |
25+
Source: HTTP GET `/status`
26+
attributes:
27+
- ref: nginx.connections.outcome
28+
requirement_level: required
29+
30+
- id: metric.nginx.http.requests
31+
type: metric
32+
unit: "requests"
33+
metric_name: nginx.http.requests
34+
stability: experimental
35+
brief: "The total number of client requests received, since NGINX was last started or reloaded."
36+
instrument: counter
37+
note: |
38+
Source: HTTP GET `/status`
39+
attributes: []
40+
41+
- id: metric.nginx.http.request.count
42+
type: metric
43+
unit: "requests"
44+
metric_name: nginx.http.request.count
45+
stability: experimental
46+
brief: "The total number of client requests received, since the last collection interval."
47+
instrument: gauge
48+
note: |
49+
Source: HTTP API `/status`
50+
attributes: []
51+
52+
- id: metric.nginx.http.response.count
53+
type: metric
54+
unit: "responses"
55+
metric_name: nginx.http.response.count
56+
stability: experimental
57+
brief: "The total number of HTTP responses since the last collection interval, grouped by status code range."
58+
instrument: gauge
59+
note: |
60+
Source: Logs `access.log`
61+
attributes:
62+
- ref: nginx.status_range
63+
requirement_level: required

catalog/nginx/registry.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/open-telemetry/weaver/v0.9.2/schemas/semconv.schema.json
2+
groups:
3+
# General NGINX OSS attributes
4+
- id: registry.nginx
5+
type: attribute_group
6+
stability: experimental
7+
display_name: General NGINX OSS Attributes
8+
brief: "Describes NGINX attributes"
9+
attributes:
10+
- id: nginx.status_range
11+
type: string
12+
stability: development
13+
brief: "A status code range or bucket for a HTTP response's status code."
14+
examples: ["1xx","2xx","3xx","4xx","5xx"]
15+
- id: nginx.connections.outcome
16+
type: string
17+
stability: development
18+
brief: "The outcome of a connection"
19+
examples: ["ACCEPTED","ACTIVE","HANDLED","READING","WRITING","WAITING"]

0 commit comments

Comments
 (0)