github.com/kamilsk/grafaman@v1.0.0-beta3.0.20201207211242-3e0d02dd84ce/README.md (about)

     1  > # 📈 grafaman
     2  >
     3  > Metrics coverage reporter for [Graphite][] and [Grafana][].
     4  
     5  [![Build][build.icon]][build.page]
     6  [![Template][template.icon]][template.page]
     7  [![Coverage][coverage.icon]][coverage.page]
     8  
     9  ## 💡 Idea
    10  
    11  ```bash
    12  $ grafaman coverage \
    13      --grafana https://grafana.api/ --dashboard DTknF4rik \
    14      --graphite https://graphite.api/ \
    15      --metrics apps.services.awesome-service
    16  # +-----------------------------------------+--------+
    17  # | Metric of apps.services.awesome-service | Hits   |
    18  # +-----------------------------------------+--------+
    19  # | jaeger.finished_spans_sampled_n         |      0 |
    20  # | rpc.client.success.ok.percentile.75     |      1 |
    21  # | rpc.client.success.ok.percentile.95     |      1 |
    22  # | rpc.client.success.ok.percentile.99     |      2 |
    23  # | rpc.client.success.ok.percentile.999    |      1 |
    24  # | ...                                     |    ... |
    25  # | go.pod-5dbdcd5dbb-6z58f.threads         |      0 |
    26  # +-----------------------------------------+--------+
    27  # |                                   Total | 65.77% |
    28  # +-----------------------------------------+--------+
    29  ```
    30  
    31  A full description of the idea is available [here][design.page].
    32  
    33  ## 🏆 Motivation
    34  
    35  At [Avito](https://tech.avito.ru/), we develop many services built on top of our excellent
    36  [PaaS](https://en.wikipedia.org/wiki/Platform_as_a_service) and internal modules. These services send
    37  a lot of metrics about their internal state which are then output to [Grafana][] dashboards.
    38  
    39  I need a tool that helps me to understand what metrics are published by services
    40  and how many of them are presented at [Grafana][] dashboards.
    41  
    42  ## 🤼‍♂️ How to
    43  
    44  ### Metrics coverage report
    45  
    46  ```bash
    47  $ grafaman coverage \
    48      --grafana https://grafana.api/ -d DTknF4rik \
    49      --graphite https://graphite.api/ \
    50      -m apps.services.awesome-service \
    51      --last 24h \
    52      --exclude='*.max' --exclude='*.mean' --exclude='*.median' --exclude='*.min' --exclude='*.sum'
    53  ```
    54  
    55  **Supported environment variables:**
    56  
    57  - APP_NAME
    58  - GRAFANA_URL
    59  - GRAFANA_DASHBOARD
    60  - GRAPHITE_URL
    61  - GRAPHITE_METRICS
    62  
    63  **Supported config files by default:**
    64  
    65  - .env.paas
    66  - app.toml
    67  
    68  located at current working directory.
    69  
    70  **Supported output formats:**
    71  
    72  - table view
    73    - default
    74    - compact
    75    - compact-lite
    76    - markdown
    77    - rounded
    78    - unicode
    79  - json
    80  ```bash
    81  $ grafaman coverage ... -f json | jq
    82  # [
    83  #   {
    84  #     "name": "apps.services.awesome-service.jaeger.finished_spans_sampled_n",
    85  #     "hits": 0
    86  #   },
    87  #   ...
    88  #   {
    89  #     "name": "apps.services.awesome-service.go.pod-5dbdcd5dbb-6z58f.threads",
    90  #     "hits": 0
    91  #   }
    92  # ]
    93  ```
    94  - tsv
    95  ```bash
    96  $ grafaman coverage ... -f tsv | column -t
    97  # apps.services.awesome-service.jaeger.finished_spans_sampled_n         0
    98  # apps.services.awesome-service.rpc.client.success.ok.percentile.75     1
    99  # apps.services.awesome-service.rpc.client.success.ok.percentile.95     1
   100  # apps.services.awesome-service.rpc.client.success.ok.percentile.99     2
   101  # apps.services.awesome-service.rpc.client.success.ok.percentile.999    1
   102  # ...                                                                 ...
   103  # apps.services.awesome-service.go.pod-5dbdcd5dbb-6z58f.threads         0
   104  ```
   105  
   106  ### Fetch metrics from [Graphite][]
   107  
   108  ```bash
   109  $ grafaman metrics --graphite https://graphite.api/ -m apps.services.awesome-service --last 24h
   110  ```
   111  
   112  ### Fetch queries from [Grafana][]
   113  
   114  ```bash
   115  $ grafaman queries --grafana https://grafana.api/ -d DTknF4rik \
   116      -m apps.services.awesome-service \
   117      --sort
   118  ```
   119  
   120  ## 🧩 Installation
   121  
   122  ### Homebrew
   123  
   124  ```bash
   125  $ brew install kamilsk/tap/grafaman
   126  ```
   127  
   128  ### Binary
   129  
   130  ```bash
   131  $ curl -sSfL https://raw.githubusercontent.com/kamilsk/grafaman/master/bin/install | sh
   132  # or
   133  $ wget -qO-  https://raw.githubusercontent.com/kamilsk/grafaman/master/bin/install | sh
   134  ```
   135  
   136  > Don't forget about [security](https://www.idontplaydarts.com/2016/04/detecting-curl-pipe-bash-server-side/).
   137  
   138  ### Source
   139  
   140  ```bash
   141  # use standard go tools
   142  $ go get github.com/kamilsk/grafaman@latest
   143  # or use egg tool
   144  $ egg tools add github.com/kamilsk/grafaman@latest
   145  ```
   146  
   147  > [egg][] is an `extended go get`.
   148  
   149  ### Bash and Zsh completions
   150  
   151  ```bash
   152  $ grafaman completion bash > /path/to/bash_completion.d/grafaman.sh
   153  $ grafaman completion zsh  > /path/to/zsh-completions/_grafaman.zsh
   154  # or autodetect
   155  $ source <(grafaman completion)
   156  ```
   157  
   158  > See `kubectl` [documentation](https://kubernetes.io/docs/tasks/tools/install-kubectl/#enabling-shell-autocompletion).
   159  
   160  ## 🤲 Outcomes
   161  
   162  ### 👨‍🔬 Research
   163  
   164  #### Metric index to autocomplete
   165  
   166  - [github.com/armon/go-radix](https://github.com/armon/go-radix)
   167  - [github.com/fanyang01/radix](https://github.com/fanyang01/radix)
   168  - [github.com/gobwas/glob](https://github.com/gobwas/glob)
   169  - [github.com/tchap/go-patricia](https://github.com/tchap/go-patricia)
   170  
   171  ---
   172  
   173  made with ❤️ for everyone
   174  
   175  [build.page]:       https://travis-ci.com/kamilsk/grafaman
   176  [build.icon]:       https://travis-ci.com/kamilsk/grafaman.svg?branch=master
   177  [coverage.page]:    https://codeclimate.com/github/kamilsk/grafaman/test_coverage
   178  [coverage.icon]:    https://api.codeclimate.com/v1/badges/eff058c43cf569c1d860/test_coverage
   179  [design.page]:      https://www.notion.so/octolab/grafaman-06e6fcd46c924126ae134c69dafbca6c?r=0b753cbf767346f5a6fd51194829a2f3
   180  [promo.page]:       https://github.com/kamilsk/grafaman
   181  [template.page]:    https://github.com/octomation/go-tool
   182  [template.icon]:    https://img.shields.io/badge/template-go--tool-blue
   183  
   184  [egg]:              https://github.com/kamilsk/egg
   185  [Graphite]:         https://graphiteapp.org/
   186  [Grafana]:          https://grafana.com/