@@ -133,7 +133,7 @@ Defaults to `undef`.
133
133
## Usage
134
134
135
135
136
- ### Grepping Metrics
136
+ ### Searching Metrics
137
137
138
138
Metrics are formatted as a JSON hash on one line.
139
139
In order to convert the metric files into a multi-line format, they can be processed with ` python -m json.tool ` as per below.
@@ -143,40 +143,68 @@ cd /opt/puppetlabs/puppet-metrics-collector
143
143
for i in < service_name> /primary.example.com/* .json; do echo " $( python -m json.tool < $i ) " > $i ; done
144
144
```
145
145
146
- You can search for useful information by performing a ` grep ` , run from inside the directory containing the metrics.
146
+ You can search for useful information by performing a ` grep ` , run from inside the directory containing the metrics
147
147
148
148
``` bash
149
149
cd /opt/puppetlabs/puppet-metrics-collector
150
- grep < metric_name> < service_name> /primary.example.com/* .json
150
+ grep -oP ' "<metric_name>,*?,' < service_name> /primary.example.com/* .json
151
+ ```
152
+
153
+ or JQ if available
154
+ ``` bash
155
+ cd /opt/puppetlabs/puppet-metrics-collector
156
+ jq ' .. |."<metric_name>"? | select(. != null)| input_filename , .' -- < service_name> /primary.example.com/* .json
151
157
```
152
158
153
159
Since the metrics are archived once per day, you can only search metrics for the current day.
154
160
To search older metrics, decompress the archived files into a subdirectory of ` /tmp ` and run your search from inside that directory.
155
161
156
- #### Grepping Puppetserver Metrics
162
+ #### Searching Puppetserver Metrics
157
163
158
164
Example:
159
165
160
166
``` bash
161
- grep average-free-jrubies puppetserver/primary.example.com/* .json
167
+ grep -oP ' "average-free-jrubies.*?,' puppetserver/primary.example.com/* .json
168
+
169
+ puppetserver/primary.example.com/20190404T170501Z.json:" average-free-jrubies" :0.9950009285369501,
170
+ puppetserver/primary.example.com/20190404T171001Z.json:" average-free-jrubies" :0.9999444653324225,
171
+ puppetserver/primary.example.com/20190404T171502Z.json:" average-free-jrubies" :0.9999993830655706,
172
+ ```
162
173
163
- puppetserver/primary.example.com/20190404T170501Z.json: " average-free-jrubies" : 0.9950009285369501,
164
- puppetserver/primary.example.com/20190404T171001Z.json: " average-free-jrubies" : 0.9999444653324225,
165
- puppetserver/primary.example.com/20190404T171502Z.json: " average-free-jrubies" : 0.9999993830655706,
174
+ ``` bash
175
+ jq ' .. |."average-free-jrubies"? | select(. != null)| input_filename , .' -- puppetserver/primary.example.com/* .json
176
+
177
+ " puppetserver/primary.example.com/20190404T170501Z.json"
178
+ 0.9950009285369501
179
+ " puppetserver/primary.example.com/20190404T171001Z.json"
180
+ 0.9999444653324225,
181
+ " puppetserver/primary.example.com/20190404T171502Z.json"
182
+ 0.9999993830655706,
166
183
```
167
184
168
- #### Grepping PuppetDB Metrics
185
+ #### Searching PuppetDB Metrics
169
186
170
187
Example:
171
188
172
189
``` bash
173
- grep queue_depth puppetdb/primary.example.com/* .json
190
+ grep -oP ' " queue_depth.*?, ' puppetdb/primary.example.com/* .json
174
191
175
192
puppetdb/primary.example.com/20190404T170501Z.json: " queue_depth" : 0,
176
193
puppetdb/primary.example.com/20190404T171001Z.json: " queue_depth" : 0,
177
194
puppetdb/primary.example.com/20190404T171502Z.json: " queue_depth" : 0,
178
195
```
179
196
197
+ ``` bash
198
+ jq ' .. |."queue_depth "? | select(. != null)| input_filename , .' -- puppetdb/primary.example.com/* .json
199
+
200
+ " puppetdb/primary.example.com/20190404T170501Z.json"
201
+ 0
202
+ " puppetdb/primary.example.com/20190404T171001Z.json"
203
+ 0
204
+ " puppetdb/primary.example.com/20190404T171502Z.json"
205
+ 0
206
+ ```
207
+
180
208
### Sharing Metrics Data
181
209
182
210
When working with Support, you may be asked for an archive of collected metrics data.
0 commit comments