Skip to content

Commit e0b1965

Browse files
Add nrdot-ibm-mq install recipe for IBM MQ via OpenTelemetry
Add recipes/newrelic/infrastructure/nrdot/ibm-mq/{debian,rhel}.yml: a config-only NRDOT Collector recipe that scrapes an existing IBM MQ mq-metric-samples (mq_prometheus) exporter and exports ibmmq_* metrics to New Relic via OTLP. Resource detection (env, ec2, gcp, azure, system) maps host.id to the IBM MQ entity identity. Includes amd64 test definitions (debian/ubuntu22/rhel9/al2023) and Ansible deploy roles that stand up IBM MQ + the exporter via Docker. Assisted-by: Claude Opus 4.8
1 parent 1d9923d commit e0b1965

8 files changed

Lines changed: 898 additions & 0 deletions

File tree

Lines changed: 277 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,277 @@
1+
# Visit our schema definition for additional information on this file format.
2+
# https://github.com/newrelic/open-install-library/blob/main/docs/recipe-spec/recipe-spec.md#schema-definition
3+
4+
name: nrdot-ibm-mq
5+
displayName: NRDOT IBM MQ
6+
description: New Relic install recipe for IBM MQ monitoring via NRDOT Collector on Debian/Ubuntu.
7+
repository: https://github.com/newrelic/nrdot-collector-releases
8+
9+
installTargets:
10+
- type: host
11+
os: linux
12+
platformFamily: debian
13+
- type: host
14+
os: linux
15+
platform: ubuntu
16+
17+
keywords:
18+
- IBM MQ
19+
- IBMMQ
20+
- NRDOT
21+
- OpenTelemetry
22+
- OTel
23+
- Messaging
24+
- Queue
25+
- Linux
26+
- Debian
27+
- Ubuntu
28+
29+
processMatch: []
30+
31+
preInstall:
32+
discoveryMode:
33+
- targeted
34+
35+
inputVars:
36+
- name: NR_CLI_IBMMQ_EXPORTER_ENDPOINT
37+
prompt: "IBM MQ Prometheus exporter address (mq-metric-samples, e.g. localhost:9157): "
38+
default: "localhost:9157"
39+
- name: NR_CLI_IBMMQ_CLUSTER_NAME
40+
prompt: "IBM MQ cluster name (optional, press Enter to skip): "
41+
default: ""
42+
43+
validationNrql: "SELECT count(*) FROM Metric WHERE metricName LIKE 'ibmmq_%' AND instrumentation.provider = 'opentelemetry' SINCE 10 minutes ago"
44+
45+
install:
46+
version: "3"
47+
silent: true
48+
49+
vars:
50+
IS_SYSTEMCTL:
51+
sh: command -v systemctl | wc -l
52+
NRDOT_ARCH:
53+
sh: if [ "$(uname -m)" = "aarch64" ]; then echo "arm64"; else echo "amd64"; fi
54+
NRDOT_VERSION:
55+
sh: curl -sf "https://api.github.com/repos/newrelic/nrdot-collector-releases/releases/latest" | grep tag_name | cut -d '"' -f 4 | sed 's/^v//' || echo "1.18.0"
56+
COLLECTOR_DISTRO: "nrdot-collector"
57+
CONFIG_DIR: "/etc/nrdot-collector"
58+
59+
tasks:
60+
default:
61+
cmds:
62+
- task: write_recipe_metadata
63+
- task: assert_pre_req
64+
- task: install_nrdot
65+
- task: create_collector_config
66+
- task: configure_service
67+
- task: restart_nrdot
68+
- task: assert_nrdot_status_ok
69+
70+
write_recipe_metadata:
71+
cmds:
72+
- |
73+
echo '{"Metadata":{"CapturedCliOutput":"true"}}' | tee {{.NR_CLI_OUTPUT}} > /dev/null
74+
75+
assert_pre_req:
76+
cmds:
77+
- |
78+
if [ "$(id -u)" != "0" ]; then
79+
echo "This newrelic install must be run under sudo or root" >&2
80+
exit 3
81+
fi
82+
- |
83+
if ! command -v curl > /dev/null 2>&1; then
84+
echo "curl is required to run the newrelic install. Please install curl and re-run the installation." >&2
85+
exit 16
86+
fi
87+
- |
88+
if [ "{{.IS_SYSTEMCTL}}" -eq 0 ]; then
89+
echo "systemd is required for the nrdot-collector service configuration." >&2
90+
exit 131
91+
fi
92+
- |
93+
# Config-only recipe: verify the existing mq_prometheus exporter is serving ibmmq_*.
94+
ENDPOINT="{{.NR_CLI_IBMMQ_EXPORTER_ENDPOINT}}"
95+
if ! curl -sf "http://${ENDPOINT}/metrics" 2>/dev/null | grep -q "^ibmmq_"; then
96+
echo "" >&2
97+
echo "Could not read IBM MQ metrics from the exporter at http://${ENDPOINT}/metrics" >&2
98+
echo "Make sure the mq-metric-samples (mq_prometheus) exporter is running and serving" >&2
99+
echo "ibmmq_* metrics, then re-run. Setup: https://github.com/ibm-messaging/mq-metric-samples" >&2
100+
exit 132
101+
fi
102+
103+
install_nrdot:
104+
cmds:
105+
- |
106+
# Idempotent: skip the download if the latest version is already installed.
107+
if dpkg -l | grep -q "^ii.*{{.COLLECTOR_DISTRO}} "; then
108+
INSTALLED_VERSION=$(dpkg -l {{.COLLECTOR_DISTRO}} | awk '/^ii/{print $3}' | sed 's/^[0-9]*://')
109+
if [ "$INSTALLED_VERSION" = "{{.NRDOT_VERSION}}" ]; then
110+
echo "{{.COLLECTOR_DISTRO}} {{.NRDOT_VERSION}} is already installed. Skipping download."
111+
exit 0
112+
fi
113+
fi
114+
echo "Installing NRDOT Collector v{{.NRDOT_VERSION}}..."
115+
NRDOT_DEB="/tmp/{{.COLLECTOR_DISTRO}}_{{.NRDOT_VERSION}}_linux_{{.NRDOT_ARCH}}.deb"
116+
curl "https://github.com/newrelic/nrdot-collector-releases/releases/download/{{.NRDOT_VERSION}}/{{.COLLECTOR_DISTRO}}_{{.NRDOT_VERSION}}_linux_{{.NRDOT_ARCH}}.deb" \
117+
--location --output "$NRDOT_DEB" 2>/dev/null
118+
DEBIAN_FRONTEND=noninteractive dpkg -i "$NRDOT_DEB" > /dev/null
119+
if [ $? -ne 0 ]; then
120+
apt-get -o DPkg::Lock::Timeout=60 install -f -y > /dev/null
121+
if [ $? -ne 0 ]; then
122+
echo "Failed to install NRDOT Collector package." >&2
123+
exit 1
124+
fi
125+
fi
126+
rm -f "$NRDOT_DEB"
127+
128+
create_collector_config:
129+
cmds:
130+
- |
131+
COLLECTOR_CONFIG="{{.CONFIG_DIR}}/ibmmq-collector-config.yaml"
132+
ENV_FILE="{{.CONFIG_DIR}}/ibmmq-env.conf"
133+
mkdir -p "{{.CONFIG_DIR}}"
134+
135+
# Config uses ${env:...} expansion; values come from the env file below
136+
# (no in-place edits). target.name is derived from the detected host.id.
137+
cat > "$COLLECTOR_CONFIG" << 'EOF'
138+
extensions:
139+
health_check:
140+
endpoint: 0.0.0.0:13133
141+
receivers:
142+
prometheus/ibmmq:
143+
config:
144+
scrape_configs:
145+
- job_name: 'ibmmq'
146+
scrape_interval: 60s
147+
scrape_timeout: 15s
148+
static_configs:
149+
- targets: ['${env:IBMMQ_EXPORTER_ENDPOINT}']
150+
processors:
151+
resourcedetection:
152+
detectors: [env, ec2, gcp, azure, system]
153+
system:
154+
resource_attributes:
155+
host.id:
156+
enabled: true
157+
host.name:
158+
enabled: true
159+
filter/ibmmq-overhead:
160+
metrics:
161+
exclude:
162+
match_type: regexp
163+
metric_names:
164+
- "^go_.*"
165+
- "^process_.*"
166+
- "^promhttp_.*"
167+
- "^scrape_.*"
168+
filter/ibmmq-queues:
169+
metrics:
170+
datapoint:
171+
- 'attributes["queue"] != nil and IsMatch(attributes["queue"], "^SYSTEM[.](ADMIN[.]|MQSC[.]|DEFAULT[.]|AUTH[.]|CHANNEL[.]|CHLAUTH[.]|CICS[.]|SYNCPOINT[.]|INTERNAL[.]|PENDING[.]|PROTECTION[.]|BROKER[.]|AMQP[.]|DOTNET[.]|REST[.]|RETAINED[.]|SELECTION[.]|DURABLE[.]|HIERARCHY[.]|DDELAY[.])")'
172+
- 'attributes["queue"] != nil and IsMatch(attributes["queue"], "^SYSTEM[.]CLUSTER[.](COMMAND|HISTORY)[.]QUEUE$")'
173+
- 'attributes["queue"] != nil and IsMatch(attributes["queue"], "^AMQ[.]")'
174+
transform/ibmmq-cleanup:
175+
metric_statements:
176+
- context: resource
177+
statements:
178+
- set(attributes["target.name"], attributes["host.id"]) where attributes["host.id"] != nil
179+
- set(attributes["cluster.name"], "${env:IBMMQ_CLUSTER_NAME}") where "${env:IBMMQ_CLUSTER_NAME}" != ""
180+
- delete_key(attributes, "service.name")
181+
- delete_key(attributes, "url.scheme")
182+
- context: datapoint
183+
statements:
184+
- delete_key(attributes, "instance")
185+
- delete_key(attributes, "job")
186+
memory_limiter/ibmmq:
187+
check_interval: 1s
188+
limit_mib: 512
189+
spike_limit_mib: 256
190+
cumulativetodelta/ibmmq: {}
191+
batch/ibmmq:
192+
send_batch_size: 1000
193+
timeout: 200ms
194+
exporters:
195+
otlp/ibmmq:
196+
endpoint: ${env:NEW_RELIC_OTLP_ENDPOINT}
197+
headers:
198+
api-key: ${env:NEW_RELIC_LICENSE_KEY}
199+
compression: gzip
200+
service:
201+
extensions: [health_check]
202+
pipelines:
203+
metrics/ibmmq:
204+
receivers: [prometheus/ibmmq]
205+
processors: [memory_limiter/ibmmq, resourcedetection, filter/ibmmq-overhead, filter/ibmmq-queues, transform/ibmmq-cleanup, cumulativetodelta/ibmmq, batch/ibmmq]
206+
exporters: [otlp/ibmmq]
207+
EOF
208+
209+
if [ "{{.NEW_RELIC_REGION}}" = "EU" ]; then
210+
OTLP_ENDPOINT="https://otlp.eu01.nr-data.net:4317"
211+
elif [ "{{.NEW_RELIC_REGION}}" = "staging" ]; then
212+
OTLP_ENDPOINT="https://staging-otlp.nr-data.net:4317"
213+
elif [ "{{.NEW_RELIC_REGION}}" = "JP" ]; then
214+
OTLP_ENDPOINT="https://otlp.jp.nr-data.net:4317"
215+
else
216+
OTLP_ENDPOINT="https://otlp.nr-data.net:4317"
217+
fi
218+
219+
printf "IBMMQ_EXPORTER_ENDPOINT=%s\n" "{{.NR_CLI_IBMMQ_EXPORTER_ENDPOINT}}" > "$ENV_FILE"
220+
printf "IBMMQ_CLUSTER_NAME=%s\n" "{{.NR_CLI_IBMMQ_CLUSTER_NAME}}" >> "$ENV_FILE"
221+
printf "NEW_RELIC_OTLP_ENDPOINT=%s\n" "$OTLP_ENDPOINT" >> "$ENV_FILE"
222+
printf "NEW_RELIC_LICENSE_KEY=%s\n" "{{.NEW_RELIC_LICENSE_KEY}}" >> "$ENV_FILE"
223+
chmod 600 "$ENV_FILE"
224+
echo "Collector config written to $COLLECTOR_CONFIG"
225+
226+
configure_service:
227+
cmds:
228+
- |
229+
DROPIN_DIR="/etc/systemd/system/{{.COLLECTOR_DISTRO}}.service.d"
230+
mkdir -p "$DROPIN_DIR"
231+
NRDOT_BIN=$(command -v {{.COLLECTOR_DISTRO}} 2>/dev/null || echo "/usr/bin/{{.COLLECTOR_DISTRO}}")
232+
{
233+
printf '[Service]\n'
234+
printf 'EnvironmentFile={{.CONFIG_DIR}}/ibmmq-env.conf\n'
235+
printf 'ExecStart=\n'
236+
printf 'ExecStart=%s --config {{.CONFIG_DIR}}/ibmmq-collector-config.yaml\n' "$NRDOT_BIN"
237+
} > "$DROPIN_DIR/ibmmq-config.conf"
238+
echo "Systemd drop-in configured."
239+
240+
restart_nrdot:
241+
cmds:
242+
- |
243+
systemctl daemon-reload
244+
systemctl reload-or-restart {{.COLLECTOR_DISTRO}}.service
245+
246+
assert_nrdot_status_ok:
247+
cmds:
248+
- |
249+
MAX_RETRIES=30
250+
TRIES=0
251+
echo "Waiting for NRDOT Collector to start..."
252+
while [ $TRIES -lt $MAX_RETRIES ]; do
253+
TRIES=$((TRIES + 1))
254+
if systemctl is-active --quiet {{.COLLECTOR_DISTRO}}.service && curl -sf http://localhost:13133 > /dev/null 2>&1; then
255+
echo "NRDOT Collector is running and healthy."
256+
echo ""
257+
echo "Configuration: {{.CONFIG_DIR}}/ibmmq-collector-config.yaml"
258+
echo "Environment: {{.CONFIG_DIR}}/ibmmq-env.conf"
259+
echo ""
260+
echo "Useful commands:"
261+
echo " Check status: sudo systemctl status nrdot-collector"
262+
echo " View logs: sudo journalctl -u nrdot-collector -f"
263+
echo " Restart: sudo systemctl restart nrdot-collector"
264+
exit 0
265+
fi
266+
sleep 2
267+
done
268+
echo "NRDOT Collector did not start in time." >&2
269+
journalctl -u {{.COLLECTOR_DISTRO}}.service --no-pager -n 50 >&2
270+
exit 31
271+
272+
postInstall:
273+
info: |2
274+
IBM MQ OTel Collector config: /etc/nrdot-collector/ibmmq-collector-config.yaml
275+
Environment file: /etc/nrdot-collector/ibmmq-env.conf
276+
Service status: systemctl status nrdot-collector
277+
View logs: journalctl -u nrdot-collector -f

0 commit comments

Comments
 (0)