Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pedro-gutierrez/vision
Simple Prometheus observability for Elixir apps
https://github.com/pedro-gutierrez/vision
Last synced: 8 days ago
JSON representation
Simple Prometheus observability for Elixir apps
- Host: GitHub
- URL: https://github.com/pedro-gutierrez/vision
- Owner: pedro-gutierrez
- License: mit
- Created: 2022-07-14T11:23:08.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-25T03:21:05.000Z (about 2 years ago)
- Last Synced: 2023-03-05T10:23:46.686Z (over 1 year ago)
- Language: Elixir
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Vision
Simple Prometheus observability for Elixir apps
## Installation
Add :vision to the list of dependencies in mix.exs:
```elixir
def deps do
[
{:vision, git: "https://github.com/pedro-gutierrez/vision.git", branch: "main"}
]
end
```## Configuration
Setup your connection to Grafana:
```elixir
config :myapp, Vision,
grafana: [
host: System.fetch_env!("GRAFANA_HOST"),
token: System.fetch_env!("GRAFANA_TOKEN")
]
```## Defining metrics and dashboards
Define a module that will define both your metrics and dashboards:
```elixir
defmodule MyApp.Metrics do
use Vision.Metrics,
otp_app: :myapp,
metrics: [
[
kind: :gauge,
name: [:host, :memory],
event: [:host, :usage],
help: "Host memory",
measurement: :memory,
unit: :percent,
thresholds: [50, 75, 90]
],
...
],
dashboards: [
some_folder: [
overview: [
variables: [
...
],
rows: [
host: [
panels: [
[metric: [:host, :memory]]
]
]
]
]
]
]
end
```Don't forget to add your module to your supervision tree:
```elixir
children = [
...
MyApp.Metrics,
...
]opts = [strategy: :one_for_one, name: ...]
Supervisor.start_link(children, opts)
```## Exposing metrics
In your router, add a path to your prometheus metrics:
```elixir
get "/metrics" do
send_resp(conn, 200, Prometheus.Format.Text.format())
end
```