Snap plugin intended to add tags based on lookup
It's used in the Snap framework.
- golang 1.7+ (needed only for building)
All OSs currently supported by snap:
- Linux/amd64
- Darwin/amd64
Fork https://github.com/michep/snap-plugin-processor-maptag
Clone repo
$ git clone https://github.com/<yourGithubID>/snap-plugin-processor-maptag
Build the plugin by running make within the cloned repo:
$ go build .
This builds the plugin.
- Set up the Snap framework
The intention of this plugin is to add tags to metrics based on regexp lookup over particular command or script execution output OR to replace value of certain tag or namespace element.
The plugin can be configured by following parameters:
maptype
- type of tag processing, propper values arenewtag
andreplace_value
.regex
- regular expression to process command output. Use golang regexp syntax. This expression should contain named capturing groups for lookup and tags adding. Required parameter.reftype
- which data use to lookup - tag values, metric static namespace element value or dynamic namespace element name; proper values aretag
,ns_name
andns_value
(only for ).refname
- metricreftype
, which value will be searched inrefgroup
results. Required parameter.ttl
- plugin cache time-to-live, in minutes. After cache was created it will not be updated till this time period expire. Optional parameter, default value - 180m (3h).cmd
- command to execute. Required parameter fornewtag
.arg[0..9]
- arguments to command. Optional parameters fornewtag
.refgroup
- named capturing group inregex
that will be used to lookup values. Required parameter fornewtag
.replace
- string to replace, can contain regexp capturing groups references (like $1). Required parameter forreplace_value
.default_value
- string to replace, if regex has no matchings. Optional parameter forreplace_value
.
Notice: Special characters in regular expressions needs to be escaped.
In this example we run iostat collector, maptag processor and file publisher to write data into file.
Documentation for Snap collector iostat plugin can be found here. Documentation for Snap file publisher plugin can be found here.
In one terminal window, open the snap daemon with log level 1 (-l 1
) and disabled plugin signing check (-t 0
):
$ snapteld -t 0 -l 1
In another terminal window:
Download and load collector, processor and publisher plugins
$ wget http://snap.ci.snap-telemetry.io/plugins/snap-plugin-collector-iostat/latest/linux/x86_64/snap-plugin-collector-iostat
$ wget http://snap.ci.snap-telemetry.io/plugins/snap-plugin-publisher-file/latest/linux/x86_64/snap-plugin-publisher-file
$ wget https://github.com/michep/snap-plugin-processor-maptag/releases/download/1/snap-plugin-processor-maptag_linux_x86_64
$ chmod 755 snap-plugin-*
$ snaptel plugin load snap-plugin-collector-iostat
$ snaptel plugin load snap-plugin-publisher-file
$ snaptel plugin load snap-plugin-processor-maptag_linux_x86_64
See available metrics for your system
$ snaptel metric list
Create a task file - see examplary task manifests in examples/tasks:
---
version: 1
schedule:
type: "simple"
interval: "10s"
workflow:
collect:
metrics:
/intel/iostat/device/*: {}
process:
- plugin_name: maptag
config:
maptype: newtag
cmd: /bin/sh
arg0: -c
arg1: ls -l /dev/disk/by-uuid/
regex: '(?P<uuid>\w{8}-\w+-\w+-\w+-\w+) -> (\.\.\/)+(?P<re_dev>\S+)'
refgroup: re_dev
reftype: tag
refname: dev
ttl: 20
publish:
- plugin_name: "file"
config:
file: "/tmp/maptag-processog.log"
Start task:
$ snaptel task create -t task.yaml
This data is published to a file /tmp/maptag-processog.log
To stop task:
$ snaptel task stop <task id>
There isn't a current roadmap for this plugin, but it is in active development. As we launch this plugin, we do not have any outstanding requirements for the next release. If you have a feature request, please add it as an issue and/or submit a pull request.
This repository is one of many plugins in Snap, a powerful telemetry framework. See the full project at http://github.com/intelsdi-x/snap To reach out to other users, head to the main framework
Snap, along with this plugin, is an Open Source software released under the Apache 2.0 License.
- Author: Mike Chepaykin