项目作者: kamilsk

项目描述 :
📈 Metrics coverage reporter for Graphite and Grafana.
高级语言: Go
项目地址: git://github.com/kamilsk/grafaman.git
创建时间: 2020-05-06T16:56:49Z
项目社区:https://github.com/kamilsk/grafaman

开源协议:MIT License

下载


📈 grafaman

Metrics coverage reporter for Graphite and Grafana.

Build
Template
Coverage

💡 Idea

  1. $ grafaman coverage \
  2. --grafana https://grafana.api/ --dashboard DTknF4rik \
  3. --graphite https://graphite.api/ \
  4. --metrics apps.services.awesome-service
  5. # +-----------------------------------------+--------+
  6. # | Metric of apps.services.awesome-service | Hits |
  7. # +-----------------------------------------+--------+
  8. # | jaeger.finished_spans_sampled_n | 0 |
  9. # | rpc.client.success.ok.percentile.75 | 1 |
  10. # | rpc.client.success.ok.percentile.95 | 1 |
  11. # | rpc.client.success.ok.percentile.99 | 2 |
  12. # | rpc.client.success.ok.percentile.999 | 1 |
  13. # | ... | ... |
  14. # | go.pod-5dbdcd5dbb-6z58f.threads | 0 |
  15. # +-----------------------------------------+--------+
  16. # | Total | 65.77% |
  17. # +-----------------------------------------+--------+

A full description of the idea is available here.

🏆 Motivation

At Avito, we develop many services built on top of our excellent
PaaS and internal modules. These services send
a lot of metrics about their internal state which are then output to Grafana dashboards.

I need a tool that helps me to understand what metrics are published by services
and how many of them are presented at Grafana dashboards.

🤼‍♂️ How to

Metrics coverage report

  1. $ grafaman coverage \
  2. --grafana https://grafana.api/ -d DTknF4rik \
  3. --graphite https://graphite.api/ \
  4. -m apps.services.awesome-service \
  5. --last 24h \
  6. --exclude='*.max' --exclude='*.mean' --exclude='*.median' --exclude='*.min' --exclude='*.sum'

Supported environment variables:

  • APP_NAME
  • GRAFANA_URL
  • GRAFANA_DASHBOARD
  • GRAPHITE_URL
  • GRAPHITE_METRICS

Supported config files by default:

  • .env.paas
  • app.toml

located at current working directory.

Supported output formats:

  • table view
    • default
    • compact
    • compact-lite
    • markdown
    • rounded
    • unicode
  • json
    1. $ grafaman coverage ... -f json | jq
    2. # [
    3. # {
    4. # "name": "apps.services.awesome-service.jaeger.finished_spans_sampled_n",
    5. # "hits": 0
    6. # },
    7. # ...
    8. # {
    9. # "name": "apps.services.awesome-service.go.pod-5dbdcd5dbb-6z58f.threads",
    10. # "hits": 0
    11. # }
    12. # ]
  • tsv
    1. $ grafaman coverage ... -f tsv | column -t
    2. # apps.services.awesome-service.jaeger.finished_spans_sampled_n 0
    3. # apps.services.awesome-service.rpc.client.success.ok.percentile.75 1
    4. # apps.services.awesome-service.rpc.client.success.ok.percentile.95 1
    5. # apps.services.awesome-service.rpc.client.success.ok.percentile.99 2
    6. # apps.services.awesome-service.rpc.client.success.ok.percentile.999 1
    7. # ... ...
    8. # apps.services.awesome-service.go.pod-5dbdcd5dbb-6z58f.threads 0

Fetch metrics from Graphite

  1. $ grafaman metrics --graphite https://graphite.api/ -m apps.services.awesome-service --last 24h

Fetch queries from Grafana

  1. $ grafaman queries --grafana https://grafana.api/ -d DTknF4rik \
  2. -m apps.services.awesome-service \
  3. --sort

🧩 Installation

Homebrew

  1. $ brew install kamilsk/tap/grafaman

Binary

  1. $ curl -sSfL https://raw.githubusercontent.com/kamilsk/grafaman/master/bin/install | sh
  2. # or
  3. $ wget -qO- https://raw.githubusercontent.com/kamilsk/grafaman/master/bin/install | sh

Don’t forget about security.

Source

  1. # use standard go tools
  2. $ go get github.com/kamilsk/grafaman@latest
  3. # or use egg tool
  4. $ egg tools add github.com/kamilsk/grafaman@latest

egg is an extended go get.

Bash and Zsh completions

  1. $ grafaman completion bash > /path/to/bash_completion.d/grafaman.sh
  2. $ grafaman completion zsh > /path/to/zsh-completions/_grafaman.zsh
  3. # or autodetect
  4. $ source <(grafaman completion)

See kubectl documentation.

🤲 Outcomes

👨‍🔬 Research

Metric index to autocomplete


made with ❤️ for everyone