-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andreas
committed
Apr 4, 2023
1 parent
ab3b828
commit de10671
Showing
12 changed files
with
115 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,51 @@ | ||
# MISeR | ||
A tool for interacting with Google Cloud Monitoring. | ||
# MISeR - A Google Cloud Monitoring Metrics Exporter | ||
|
||
MISeR is a [Prometheus Exporter](https://prometheus.io/docs/instrumenting/exporters/#exporters-and-integrations) for [Google Cloud Monitoring](https://cloud.google.com/monitoring/) metrics. | ||
|
||
It is written in Elixir and originated at [Massdriver](https://massdriver.cloud). | ||
|
||
# Features | ||
|
||
* Export metrics from Google Cloud Monitoring to Prometheus | ||
* Simple configuration of metrics using metric type prefixes | ||
* Auto discovery of resources via tags | ||
* Adds any available dimension labels to metrics | ||
|
||
# Configuration | ||
|
||
## Authentication | ||
|
||
The exporter is configured to use [Google Application Default Credentials](https://cloud.google.com/docs/authentication/production#automatically) to authenticate with Google Cloud Monitoring. | ||
|
||
## Configuration | ||
|
||
The exporter is configured using a YAML file. The following options are available: | ||
|
||
### Required | ||
|
||
| Option | Description | | ||
|--------|-------------| | ||
| `project_id` | The Google Cloud project ID to export metrics from. | | ||
| `metric_type_prefixes` | A list of metric type prefixes to export. | | ||
|
||
### Optional | ||
|
||
| Option | Description | | ||
|--------|-------------| | ||
| `user_labels` | User-defined [labels](https://cloud.google.com/resource-manager/docs/creating-managing-labels) to filter on. | | ||
|
||
### Example | ||
|
||
```yaml | ||
project_id: "massdriver" | ||
metric_type_prefixes: | ||
- "cloudsql.googleapis.com/database/cpu" | ||
user_labels: | ||
environment: "prod" | ||
``` | ||
# Scraping | ||
By default, the exporter is exposed on port `9090`, path `/metrics`. | ||
|
||
Metrics are queried at the time of scraping and are not cached. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
import Config | ||
|
||
config :miser, Miser.Config, file: "/config/config.yml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
import Config | ||
|
||
config :miser, Miser, YamlElixir.read_from_file!("/config/config.yml") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
import Config | ||
|
||
config :miser, Miser.Config, | ||
project_id: "my_project_id", | ||
metric_type_prefixes: ["cloudsql.googleapis.com/database/cpu"], | ||
user_labels: %{ | ||
"environment" => "dev" | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
defmodule Miser.Config do | ||
@moduledoc """ | ||
Managed Miser config.any() | ||
This useful wrapper lets us evaluate config files for when this thing is configured on k8s. | ||
""" | ||
|
||
def configure do | ||
Application.get_env(:miser, __MODULE__) | ||
|> Keyword.get(:file) | ||
|> case do | ||
nil -> :ok | ||
file -> evaluate_config_file(file) | ||
end | ||
end | ||
|
||
def project_id do | ||
Application.fetch_env!(:miser, __MODULE__) | ||
|> Keyword.fetch!(:project_id) | ||
end | ||
|
||
def user_labels do | ||
Application.fetch_env!(:miser, __MODULE__) | ||
|> Keyword.get(:user_labels, []) | ||
end | ||
|
||
def metric_type_prefixes do | ||
Application.fetch_env!(:miser, __MODULE__) | ||
|> Keyword.fetch!(:metric_type_prefixes) | ||
end | ||
|
||
def evaluate_config_file(path) do | ||
config_map = YamlElixir.read_from_file!(path) | ||
|
||
config = [ | ||
project_id: Map.fetch!(config_map, "project_id"), | ||
user_labels: Map.get(config_map, "user_labels", %{}), | ||
metric_type_prefixes: Map.fetch!(config_map, "metric_type_prefixes") | ||
] | ||
|
||
Application.put_env(:miser, __MODULE__, config) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.