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

optional TERASLICE_DISPLAY_URL env parameter for metric url labels #7

Merged
merged 3 commits into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ So far it works like this:

```bash
TERASLICE_URL="https://localhost" \
TERASLICE_DISPLAY_URL="https://teraslice-xyz.lan" \
briend marked this conversation as resolved.
Show resolved Hide resolved
DEBUG=True \
NODE_EXTRA_CA_CERTS=/path/to/ca.crt \
node dist/index.js | bunyan
Expand All @@ -19,6 +20,7 @@ All options are passed as environment variables

```bash
TERASLICE_URL="https://localhost" \
TERASLICE_DISPLAY_URL="https://teraslice-xyz.lan" \
DEBUG=True \
NODE_EXTRA_CA_CERTS=/path/to/ca.crt \
PORT=4242 \
Expand All @@ -31,6 +33,7 @@ The `TERASLICE_URL` is the only environment variable that is required.
### Environment variables

* `TERASLICE_URL` - URL to the Teraslice Instance to Monitor
* `TERASLICE_DISPLAY_URL` - Optional override of TERASLICE_URL for metric label purposes only
* `DEBUG` - Enable debug logging
* `NODE_EXTRA_CA_CERTS` - Standard Node variable to specify CA cert for SSL
connections
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ declare let process : {
DEBUG: string,
PORT: number,
TERASLICE_URL: string
TERASLICE_DISPLAY_URL: string
TERASLICE_QUERY_DELAY: number
}
};
Expand Down
8 changes: 7 additions & 1 deletion src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,14 @@ function generateExecutionVersions(terasliceStats:TerasliceStats, labels:any) {
export function updateTerasliceMetrics(terasliceStats: TerasliceStats): void {
metricsRegistry.resetMetrics();

let baseURLLabel = terasliceStats.baseUrl.toString()

if (process?.env?.TERASLICE_DISPLAY_URL) {
briend marked this conversation as resolved.
Show resolved Hide resolved
baseURLLabel = process?.env?.TERASLICE_DISPLAY_URL?.toLowerCase()
}

const globalLabels = {
url: terasliceStats.baseUrl.toString(),
url: baseURLLabel,
name: terasliceStats.info.name,
};
// NOTE: This set of labels expands out to including 'name' twice, right now
Expand Down