Copy tags of EC2 instance to metrics.
Atelemetry
plugin.
Click to expand
const telemetry = require('@telemetry-js/telemetry')()
const tags = require('@telemetry-js/processor-ec2-instance-tags')
telemetry.task()
.process(tags)
// Or with options
telemetry.task()
.process(tags, { include: ['name', 'version'] })
case
: optional function to normalize a tag. E.g.(key) => key.toLowerCase()
. The default behavior is to lowercase the key and strip any characters outside of[a-z0-9]
. If the EC2 instance has aProject
tag for example, metrics will be tagged withproject
.include
: optional array of tags to include, normalized. E.g.['project']
. By default all tags are included.filter
: optional function to filter tags. E.g.(key) => key === 'project'
. Takes precedence overoptions.include
.
By default, each instance of this plugin fetches EC2 instance metadata and tags itself. To only fetch once (with a semiglobal cache) use:
const tags = require('@telemetry-js/processor-ec2-instance-tags').cached
With npm do:
npm install @telemetry-js/processor-ec2-instance-tags
This project is kindly sponsored by Reason Cybersecurity Ltd.
MIT © Vincent Weevers