Giter Club home page Giter Club logo

metrin's Introduction

metrin

Very simple CloudWatch CLI for Zabbix/Sensu/Mackerel/etc.

Installation

Download binary from releases.

Put it into your $PATH.

Usage

View it first.

$ metrin --help

Set credentials and region

Use environmental variables. AWS_REGION, AWS_PROFILE, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY

Subcommands

check

Act as Nagios/Sensu plugin style.

Example: Check an EC2 instance's CPU, critical if > 50%

$ metrin --namespace AWS/EC2 --metric-name CPUUtilization --statistic Average --dimension InstanceId:i-1234abcd1234abcde check --critical-gt 50
CloudWatch OK, got `22.534000` (Percent)
Params: {
  Dimensions: [{
      Name: "InstanceId",
      Value: "i-1234abcd1234abcde"
    }],
  EndTime: 2016-12-04 23:24:55 +0900 JST,
  MetricName: "CPUUtilization",
  Namespace: "AWS/EC2",
  Period: 60,
  StartTime: 2016-12-04 23:19:55 +0900 JST,
  Statistics: ["Average"]
}

Run command below to view full option list.

$ metrin check --help

print

Print metric statistic value with given format (--template).

Example: Metric path, value, timestamp, tab separated (Default template)

$ metrin --namespace AWS/EC2 --metric-name CPUUtilization --statistic Average --start-time -900 --period 300 --dimension InstanceId:i-abcd1234abcd12345 print
CloudWatch.InstanceId.i-abcd1234abcd12345.CPUUtilization.Average	1.566	1480861800
CloudWatch.InstanceId.i-abcd1234abcd12345.CPUUtilization.Average	1.536	1480862100

Example: Single value only output (for Zabbix, etc.)

$ metrin --namespace AWS/EC2 --metric-name CPUUtilization --statistic Average --start-time -900 --period 300 --dimension InstanceId:i-abcd1234abcd12345 print --template '{{.Datapoint.Average}}' --last-value-only
1.536

Run command below to view full option list.

$ metrin print --help

This feature is using text/template package.

Additional functions are unixtime (Convert .Datapoint.Timestamp to UNIX timestamp), deref (Convert *float64 to float64, combine usage with printf), getvalue (Get statistic value dynamically).

See print.go.

debug

For troubleshooting.

FAQ.

No datapoints?

Adjust --start-time, --end-time, --period.

Multiple dimensions?

--dimension dim1key:dim1value --dimension dim2key:dim2value

metrin's People

Contributors

renovate-bot avatar renovate[bot] avatar y13i avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.