Skip to content

Commit

Permalink
Merge pull request #482 from mackerelio/move-mackerel-plugin-json
Browse files Browse the repository at this point in the history
Move mackerel-plugin-json to other repository
  • Loading branch information
shibayu36 authored Jan 10, 2018
2 parents 9ad7ca7 + 797df8c commit 545a3ea
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 387 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Documentation for each plugin is located in its respective sub directory.
* [mackerel-plugin-haproxy](./mackerel-plugin-haproxy/README.md)
* [mackerel-plugin-inode](./mackerel-plugin-inode/README.md)
* [mackerel-plugin-jmx-jolokia](./mackerel-plugin-jmx-jolokia/README.md)
* [mackerel-plugin-json](./mackerel-plugin-json/README.md)
* [mackerel-plugin-jvm](./mackerel-plugin-jvm/README.md)
* [mackerel-plugin-linux](./mackerel-plugin-linux/README.md)
* [mackerel-plugin-mailq](./mackerel-plugin-mailq/README.md)
Expand Down
112 changes: 2 additions & 110 deletions mackerel-plugin-json/README.md
Original file line number Diff line number Diff line change
@@ -1,112 +1,4 @@
mackerel-plugin-json
====================
=======================

Json custom metrics plugin for mackerel.io agent.

## Synopsis

```
mackerel-plugin-json -url=<url to get JSON> [-prefix=<prefix for a metric name>] [-insecure] [-include=<expression>] [-exclude=<expression>]
```

- `-url` always needs to be specified.
- If you want to skip a SSL certificate validation (e.g. using a self-signed certificate), you need to specify `-insecure`.
- If you want to get only metrics that matches a regular expression, specify the expression with `-include`. If you want to get only ones that doesn't match an expression, use `-exclude`.
- Metrics that have non-number value (string, `null`, etc.) are omitted.
- Arrays are supported. Metrics' name will contain a serial number like `custom.elements.0.xxx`, `custom.elements.1.xxx` and so on.

## Example of mackerel-agent.conf

```
[plugin.metrics.jolokia]
command = mackerel-plugin-json -url='http://127.0.0.1:8778/jolokia/read/java.lang:type=Memory' -include='HeapMemoryUsage' -prefix='custom.jolokia'
```

## Examples of output from the plugin

Given the following JSON:

```
curl -s http://127.0.0.1:8778/jolokia/read/java.lang:type=Memory | jq .
{
"request": {
"mbean": "java.lang:type=Memory",
"type": "read"
},
"value": {
"ObjectPendingFinalizationCount": 0,
"Verbose": false,
"HeapMemoryUsage": {
"init": 1073741824,
"committed": 1069023232,
"max": 1069023232,
"used": 994632048
},
"NonHeapMemoryUsage": {
"init": 2555904,
"committed": 44040192,
"max": 1350565888,
"used": 43070016
},
"ObjectName": {
"objectName": "java.lang:type=Memory"
}
},
"timestamp": 1455079714,
"status": 200
}
```

The output should be:

```
# Option : -url='http://127.0.0.1:8778/jolokia/read/java.lang:type=Memory'
custom.value.HeapMemoryUsage.used 994632048.000000 1503586907
custom.value.HeapMemoryUsage.init 1073741824.000000 1503586907
custom.value.HeapMemoryUsage.max 1069023232.000000 1503586907
custom.timestamp 1455079714.000000 1503586907
custom.status 200.000000 1503586907
custom.value.NonHeapMemoryUsage.committed 44040192.000000 1503586907
custom.value.NonHeapMemoryUsage.max 1350565888.000000 1503586907
custom.value.NonHeapMemoryUsage.used 43070016.000000 1503586907
custom.value.NonHeapMemoryUsage.init 2555904.000000 1503586907
custom.value.HeapMemoryUsage.committed 1069023232.000000 1503586907
```

```
# Option : -url='http://127.0.0.1:8778/jolokia/read/java.lang:type=Memory' -include='\.HeapMemoryUsage'
custom.value.HeapMemoryUsage.init 1073741824.000000 1503587081
custom.value.HeapMemoryUsage.committed 1069023232.000000 1503587081
custom.value.HeapMemoryUsage.max 1069023232.000000 1503587081
custom.value.HeapMemoryUsage.used 994632048.000000 1503587081
```

```
# Option : -url='http://127.0.0.1:8778/jolokia/read/java.lang:type=Memory' -exclude='(timestamp|status)'
custom.value.HeapMemoryUsage.init 1073741824.000000 1503587166
custom.value.HeapMemoryUsage.committed 1069023232.000000 1503587166
custom.value.HeapMemoryUsage.max 1069023232.000000 1503587166
custom.value.HeapMemoryUsage.used 994632048.000000 1503587166
custom.value.NonHeapMemoryUsage.max 1350565888.000000 1503587166
custom.value.NonHeapMemoryUsage.used 43070016.000000 1503587166
custom.value.NonHeapMemoryUsage.init 2555904.000000 1503587166
custom.value.NonHeapMemoryUsage.committed 44040192.000000 1503587166
```

You can also get metrics from any APIs that returns a JSON. For example:

```
# Option : -url='https://[your-github-token]@api.github.com/repos/doublemarket/private-repo' -include='(_count|watchers|issues)' -prefix='custom.github.some-private-repo'
custom.github.private-repo.open_issues_count 1171.000000 1503587879
custom.github.private-repo.open_issues 1171.000000 1503587879
custom.github.private-repo.network_count 15042.000000 1503587879
custom.github.private-repo.forks_count 15042.000000 1503587879
custom.github.private-repo.stargazers_count 36733.000000 1503587879
custom.github.private-repo.subscribers_count 2444.000000 1503587879
custom.github.private-repo.watchers_count 36733.000000 1503587879
custom.github.private-repo.watchers 36733.000000 1503587879
```
This plugin has been moved to github.com/mackerelio/mackerel-plugin-json
136 changes: 0 additions & 136 deletions mackerel-plugin-json/lib/json.go

This file was deleted.

88 changes: 0 additions & 88 deletions mackerel-plugin-json/lib/json_test.go

This file was deleted.

10 changes: 0 additions & 10 deletions mackerel-plugin-json/lib/testdata/array.json

This file was deleted.

13 changes: 0 additions & 13 deletions mackerel-plugin-json/lib/testdata/array_within.json

This file was deleted.

Loading

0 comments on commit 545a3ea

Please sign in to comment.