Skip to content

Commit 5ceb8e5

Browse files
committed
[jmx-scraper] Create weaver model for jmx-scraper metrics #2072
- tested weaver model locally as well as on docker - completed Makefile
1 parent f7bb923 commit 5ceb8e5

File tree

3 files changed

+67
-66
lines changed

3 files changed

+67
-66
lines changed

jmx-scraper/model/metrics.yaml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
groups:
2-
- id: jvm.class.loaded
2+
- id: jvm.classes.loaded
33
type: metric
4-
brief: "Number of classes loaded by the JVM."
5-
metric_name: jvm.class.loaded
4+
brief: "number of loaded classes"
5+
metric_name: jvm.classes.loaded
66
instrument: updowncounter
77
unit: "{class}"
88
stability: beta
99

1010
- id: jvm.gc.collections.count
1111
type: metric
12-
brief: "Total number of garbage collection that have occurred."
12+
brief: "total number of collections that have occurred"
1313
metric_name: jvm.gc.collections.count
1414
instrument: counter
1515
unit: "{collection}"
@@ -20,7 +20,7 @@ groups:
2020

2121
- id: jvm.gc.collections.elapsed
2222
type: metric
23-
brief: "Approximate accumulated garbage collection elapsed time in milliseconds."
23+
brief: "the approximate accumulated collection elapsed time in milliseconds"
2424
metric_name: jvm.gc.collections.elapsed
2525
instrument: counter
2626
unit: ms
@@ -31,71 +31,71 @@ groups:
3131

3232
- id: jvm.memory.heap.committed
3333
type: metric
34-
brief: "Current committed heap memory usage."
34+
brief: "current heap size"
3535
metric_name: jvm.memory.heap.committed
3636
instrument: gauge
3737
unit: By
3838
stability: beta
3939

4040
- id: jvm.memory.heap.init
4141
type: metric
42-
brief: "Initial heap memory usage."
42+
brief: "initial heap size"
4343
metric_name: jvm.memory.heap.init
4444
instrument: gauge
4545
unit: By
4646
stability: beta
4747

4848
- id: jvm.memory.heap.max
4949
type: metric
50-
brief: "Maximum heap memory usage."
50+
brief: "max heap size"
5151
metric_name: jvm.memory.heap.max
5252
instrument: gauge
5353
unit: By
5454
stability: beta
5555

5656
- id: jvm.memory.heap.used
5757
type: metric
58-
brief: "Current heap memory usage."
58+
brief: "current heap usage"
5959
metric_name: jvm.memory.heap.used
6060
instrument: gauge
6161
unit: By
6262
stability: beta
6363

6464
- id: jvm.memory.nonheap.committed
6565
type: metric
66-
brief: "Current committed non-heap memory usage."
66+
brief: "current non-heap size"
6767
metric_name: jvm.memory.nonheap.committed
6868
instrument: gauge
6969
unit: By
7070
stability: beta
7171

7272
- id: jvm.memory.nonheap.init
7373
type: metric
74-
brief: "Initial non-heap memory usage."
74+
brief: "initial non-heap size"
7575
metric_name: jvm.memory.nonheap.init
7676
instrument: gauge
7777
unit: By
7878
stability: beta
7979

8080
- id: jvm.memory.nonheap.max
8181
type: metric
82-
brief: "Maximum non-heap memory usage."
82+
brief: "max non-heap size"
8383
metric_name: jvm.memory.nonheap.max
8484
instrument: gauge
8585
unit: By
8686
stability: beta
8787

8888
- id: jvm.memory.nonheap.used
8989
type: metric
90-
brief: "Current non-heap memory usage."
90+
brief: "current non-heap usage"
9191
metric_name: jvm.memory.nonheap.used
9292
instrument: gauge
9393
unit: By
9494
stability: beta
9595

9696
- id: jvm.memory.pool.committed
9797
type: metric
98-
brief: "Current memory pool committed usage."
98+
brief: "current memory pool size"
9999
metric_name: jvm.memory.pool.committed
100100
instrument: gauge
101101
unit: By
@@ -106,7 +106,7 @@ groups:
106106

107107
- id: jvm.memory.pool.init
108108
type: metric
109-
brief: "Initial memory pool usage."
109+
brief: "initial memory pool size"
110110
metric_name: jvm.memory.pool.init
111111
instrument: gauge
112112
unit: By
@@ -117,7 +117,7 @@ groups:
117117

118118
- id: jvm.memory.pool.max
119119
type: metric
120-
brief: "Maximum memory pool usage."
120+
brief: "max memory pool size"
121121
metric_name: jvm.memory.pool.max
122122
instrument: gauge
123123
unit: By
@@ -128,7 +128,7 @@ groups:
128128

129129
- id: jvm.memory.pool.used
130130
type: metric
131-
brief: "Current memory pool used usage."
131+
brief: "current memory pool usage"
132132
metric_name: jvm.memory.pool.used
133133
instrument: gauge
134134
unit: By
@@ -139,7 +139,7 @@ groups:
139139

140140
- id: jvm.threads.count
141141
type: metric
142-
brief: "Current number of thread count"
142+
brief: "current number of thread count"
143143
metric_name: jvm.threads.count
144144
instrument: gauge
145145
unit: "{thread}"

jmx-scraper/src/main/resources/jvm.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,31 @@ rules:
3535
mapping:
3636
HeapMemoryUsage.committed:
3737
metric: heap.committed
38-
desc: current heap usage
38+
desc: current heap size
3939
type: gauge
4040
HeapMemoryUsage.init:
4141
metric: heap.init
42-
desc: current heap usage
42+
desc: initial heap size
4343
type: gauge
4444
HeapMemoryUsage.max:
4545
metric: heap.max
46-
desc: current heap usage
46+
desc: max heap size
4747
type: gauge
4848
HeapMemoryUsage.used:
4949
metric: heap.used
5050
desc: current heap usage
5151
type: gauge
5252
NonHeapMemoryUsage.committed:
5353
metric: nonheap.committed
54-
desc: current non-heap usage
54+
desc: current non-heap size
5555
type: gauge
5656
NonHeapMemoryUsage.init:
5757
metric: nonheap.init
58-
desc: current non-heap usage
58+
desc: initial non-heap size
5959
type: gauge
6060
NonHeapMemoryUsage.max:
6161
metric: nonheap.max
62-
desc: current non-heap usage
62+
desc: max non-heap size
6363
type: gauge
6464
NonHeapMemoryUsage.used:
6565
metric: nonheap.used

jmx-scraper/templates/registry/rules/jvm.yaml.j2

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
---
2-
2+
{# Define a variable for the common "jvm.memory." prefix #}
3+
{%- set jvm_memory_prefix = "jvm.memory." %}
34
rules:
45
# Rule for ClassLoading metrics
56
- bean: java.lang:type=ClassLoading
67
mapping:
78
LoadedClassCount:
8-
{%- set m_class_loaded = (ctx.groups | selectattr("id", "equalto", "jvm.class.loaded") | first) %}
9-
metric: jvm.classes.loaded
9+
{%- set m_class_loaded = (ctx.groups | selectattr("id", "equalto", "jvm.classes.loaded") | first) %}
10+
metric: {{ m_class_loaded.metric_name | safe }}
1011
type: gauge
1112
unit: "{{ m_class_loaded.unit | safe }}"
12-
desc: number of loaded classes
13+
desc: {{ m_class_loaded.brief | safe }}
1314

1415
# Rule for Garbage Collector metrics
1516
- bean: java.lang:type=GarbageCollector,name=*
@@ -20,15 +21,15 @@ rules:
2021
metric: {{ m.id | safe }}
2122
type: {{ m.instrument | safe }}
2223
unit: "{{ m.unit | safe }}"
23-
desc: total number of collections that have occurred
24+
desc: {{ m.brief | safe }}
2425
metricAttribute:
2526
name: param(name)
2627
{%- elif m.id == "jvm.gc.collections.elapsed" %}
2728
CollectionTime:
2829
metric: {{ m.id | safe}}
2930
type: {{ m.instrument | safe }}
3031
unit: {{ m.unit | safe }}
31-
desc: the approximate accumulated collection elapsed time in milliseconds
32+
desc: {{ m.brief | safe }}
3233
metricAttribute:
3334
name: param(name)
3435
{%- endif %}
@@ -37,51 +38,51 @@ rules:
3738
# Rule for Heap and Non-Heap Memory metrics
3839
- bean: java.lang:type=Memory
3940
unit: By
40-
prefix: jvm.memory.
41+
prefix: {{ jvm_memory_prefix | safe }}
4142
mapping:
42-
{%- for m in ctx.groups if m.id.startswith("jvm.memory.heap") %}
43-
{%- if m.id == "jvm.memory.heap.committed" %}
43+
{%- for m in ctx.groups if m.id.startswith(jvm_memory_prefix + "heap") %}
44+
{%- if m.id == jvm_memory_prefix + "heap.committed" %}
4445
HeapMemoryUsage.committed:
45-
metric: heap.committed
46-
desc: current heap usage
46+
metric: {{ m.id | replace(jvm_memory_prefix, "") | safe }}
47+
desc: {{ m.brief | safe }}
4748
type: gauge
48-
{%- elif m.id == "jvm.memory.heap.init" %}
49+
{%- elif m.id == jvm_memory_prefix + "heap.init" %}
4950
HeapMemoryUsage.init:
50-
metric: heap.init
51-
desc: current heap usage
51+
metric: {{ m.id | replace(jvm_memory_prefix, "") | safe }}
52+
desc: {{ m.brief | safe }}
5253
type: gauge
53-
{%- elif m.id == "jvm.memory.heap.max" %}
54+
{%- elif m.id == jvm_memory_prefix + "heap.max" %}
5455
HeapMemoryUsage.max:
55-
metric: heap.max
56-
desc: current heap usage
56+
metric: {{ m.id | replace(jvm_memory_prefix, "") | safe }}
57+
desc: {{ m.brief | safe }}
5758
type: gauge
58-
{%- elif m.id == "jvm.memory.heap.used" %}
59+
{%- elif m.id == jvm_memory_prefix + "heap.used" %}
5960
HeapMemoryUsage.used:
60-
metric: heap.used
61-
desc: current heap usage
61+
metric: {{ m.id | replace(jvm_memory_prefix, "") | safe }}
62+
desc: {{ m.brief | safe }}
6263
type: gauge
6364
{%- endif %}
6465
{%- endfor %}
65-
{%- for m in ctx.groups if m.id.startswith("jvm.memory.nonheap") %}
66-
{%- if m.id == "jvm.memory.nonheap.committed" %}
66+
{%- for m in ctx.groups if m.id.startswith(jvm_memory_prefix + "nonheap") %}
67+
{%- if m.id == jvm_memory_prefix + "nonheap.committed" %}
6768
NonHeapMemoryUsage.committed:
68-
metric: nonheap.committed
69-
desc: current non-heap usage
69+
metric: {{ m.id | replace(jvm_memory_prefix, "") | safe }}
70+
desc: {{ m.brief | safe }}
7071
type: gauge
71-
{%- elif m.id == "jvm.memory.nonheap.init" %}
72+
{%- elif m.id == jvm_memory_prefix + "nonheap.init" %}
7273
NonHeapMemoryUsage.init:
73-
metric: nonheap.init
74-
desc: current non-heap usage
74+
metric: {{ m.id | replace(jvm_memory_prefix, "") | safe }}
75+
desc: {{ m.brief | safe }}
7576
type: gauge
76-
{%- elif m.id == "jvm.memory.nonheap.max" %}
77+
{%- elif m.id == jvm_memory_prefix + "nonheap.max" %}
7778
NonHeapMemoryUsage.max:
78-
metric: nonheap.max
79-
desc: current non-heap usage
79+
metric: {{ m.id | replace(jvm_memory_prefix, "") | safe }}
80+
desc: {{ m.brief | safe }}
8081
type: gauge
81-
{%- elif m.id == "jvm.memory.nonheap.used" %}
82+
{%- elif m.id == jvm_memory_prefix + "nonheap.used" %}
8283
NonHeapMemoryUsage.used:
83-
metric: nonheap.used
84-
desc: current non-heap usage
84+
metric: {{ m.id | replace(jvm_memory_prefix, "") | safe }}
85+
desc: {{ m.brief | safe }}
8586
type: gauge
8687
{%- endif %}
8788
{%- endfor %}
@@ -93,22 +94,22 @@ rules:
9394
metricAttribute:
9495
name: param(name)
9596
mapping:
96-
{%- for m in ctx.groups if m.id.startswith("jvm.memory.pool") %}
97-
{%- if m.id == "jvm.memory.pool.committed" %}
97+
{%- for m in ctx.groups if m.id.startswith(jvm_memory_prefix + "pool") %}
98+
{%- if m.id == jvm_memory_prefix + "pool.committed" %}
9899
Usage.committed:
99-
metric: jvm.memory.pool.committed
100+
metric: {{ m.id | safe }}
100101
desc: current memory pool usage
101-
{%- elif m.id == "jvm.memory.pool.init" %}
102+
{%- elif m.id == jvm_memory_prefix + "pool.init" %}
102103
Usage.init:
103-
metric: jvm.memory.pool.init
104+
metric: {{ m.id | safe }}
104105
desc: current memory pool usage
105-
{%- elif m.id == "jvm.memory.pool.max" %}
106+
{%- elif m.id == jvm_memory_prefix + "pool.max" %}
106107
Usage.max:
107-
metric: jvm.memory.pool.max
108+
metric: {{ m.id | safe }}
108109
desc: current memory pool usage
109-
{%- elif m.id == "jvm.memory.pool.used" %}
110+
{%- elif m.id == jvm_memory_prefix + "pool.used" %}
110111
Usage.used:
111-
metric: jvm.memory.pool.used
112+
metric: {{ m.id | safe }}
112113
desc: current memory pool usage
113114
{%- endif %}
114115
{%- endfor %}

0 commit comments

Comments
 (0)