Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide documentation on overriding runtime config & config APIs #687

Merged
merged 3 commits into from
Aug 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion docs/configuration/v1.x/runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ This article covers an overview of all the knobs that you can tweak to align the

Promitor runtime is configured by mounting a volume to `/config/runtime.yaml`.

Here is a complete example:
We provide the capability to override te runtime YAML via [environment variables](#overriding-configuration-with-environment-variables), if you have the need for it.

Here is a complete example of the runtime YAML:

```yaml
server:
Expand Down Expand Up @@ -143,4 +145,24 @@ telemetry:
defaultVerbosity: error # Optional. Default: error
```

# Overriding configuration with environment variables

In certain scenarios you'd like to override what was configured in the runtime YAML. Therefor we provide the capability to override them via environment variables.

Every environment variable should be prefixed with `PROMITOR_YAML_OVERRIDE_` followed by the YAML hierarchy where every level is replaced with `__` rather than a tab. Environment variables are not case sensitive.

Our runtime configuration API endpoint allows you to verify if it was overriden and returns what will be used to run Promitor.

> :warning: Depending on the configuration that is changed it may be required to restart Promitor, for example changing the HTTP port.

## Example

Let's say we want to override the following HTTP port:
```yaml
server:
httpPort: 80
```

An environment variable called `PROMITOR_YAML_OVERRIDE_server__httpPort` can be provided which specifies the new port.

[← back](/)
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ And there is more on the way - Check our [backlog](https://github.com/tomkerkhov
- [Logging & External Providers](configuration/v0.x/#logging)
- **Operations**
- [Azure Resource Manager API - Consumption & Throttling](operations#azure-resource-manager-api---consumption--throttling)
- [Configuration REST APIs](operations#configuration-rest-apis)
- [Health](operations#health)
- **Walkthroughs**
- [Deploying Promitor, Prometheus, and Grafana on an AKS Cluster](/walkthrough)
Expand Down
15 changes: 15 additions & 0 deletions docs/operations/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,19 @@ Metric provides following labels:

You can read more about the Azure Resource Manager limitations on [docs.microsoft.com](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-request-limits).

# Configuration REST APIs
In order to run Promitor certain aspects have to be configured. Once up & running, you typically do not touch or open the configuration anymore and just intereact with Promitor.

For some scenarios it can be useful to know what was configured:
- Metrics are not showing up in the scraping endpoint, was it configured correctly?
- We don't see telemetry in our sink, was it turned on?
- ...

Therefor we provide the following REST APIs:

- **Get Metrics Declaration** - Provides a list of metrics that are being scraped
- **Get Runtime Configuration** - Provides an overview of how the runtime is configured

For security reasons, some sections of the configuration might be sanitized in the response to avoid leaking secrets.

[← back](/)
4 changes: 2 additions & 2 deletions src/Promitor.Core/EnvironmentVariables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ public class EnvironmentVariables
{
public class Authentication
{
public const string ApplicationId = "PROMITOR_AUTH_APPID";
public const string ApplicationKey = "PROMITOR_AUTH_APPKEY";
public const string ApplicationId = "AUTH_APPID";
public const string ApplicationKey = "AUTH_APPKEY";
}
}
}
3 changes: 2 additions & 1 deletion src/Promitor.Scraper.Host/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ private static IConfigurationRoot CreateConfiguration()
.SetBasePath(Directory.GetCurrentDirectory())
.AddYamlFile("/config/runtime.yaml", optional: false, reloadOnChange: true)
.AddEnvironmentVariables()
.AddEnvironmentVariables(prefix: "PROMITOR:")
.AddEnvironmentVariables(prefix: "PROMITOR_") // Used for all environment variables for Promitor
.AddEnvironmentVariables(prefix: "PROMITOR_YAML_OVERRIDE_") // Used to overwrite runtime YAML
.Build();

return configuration;
Expand Down