From d893c9261e95621073a7ee44044b99777bd5081c Mon Sep 17 00:00:00 2001 From: Krastin Krastev Date: Mon, 10 Jan 2022 17:37:38 +0100 Subject: [PATCH 1/3] adding JSON examples to /docs/connect/observability/ui-visualization --- .../observability/ui-visualization.mdx | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/website/content/docs/connect/observability/ui-visualization.mdx b/website/content/docs/connect/observability/ui-visualization.mdx index e21631a482..9a9056ff07 100644 --- a/website/content/docs/connect/observability/ui-visualization.mdx +++ b/website/content/docs/connect/observability/ui-visualization.mdx @@ -66,6 +66,9 @@ service named `prometheus-server` so each Consul agent can reach it on A full configuration to enable Prometheus is given below. + + + ```hcl ui_config { enabled = true @@ -76,6 +79,28 @@ ui_config { } ``` + + + +```json +{ + "ui_config": [ + { + "enabled": true, + "metrics_provider": "prometheus", + "metrics_proxy": [ + { + "base_url": "http://prometheus-server" + } + ] + } + ] +} +``` + + + + Similarly, to configure the UI on Kubernetes, use this [reference](/docs/k8s/connect/observability/metrics). ## Configuring Dashboard URLs @@ -114,6 +139,31 @@ ui_config { without horizontal scrolling in the example above however this needs to be a normal single-line string value in an HCL configuration file. + + + +```json +{ + "ui_config": [ + { + "dashboard_url_templates": [ + { + "service": "https://grafana.example.com/d/lDlaj-NGz/ + service-overview?orgId=1\u0026var-service={{Service.Name}}\u0026 + var-namespace={{Service.Namespace}}\u0026 + var-partition={{Service.Partition}}\u0026var-dc={{Datacenter}}" + } + ], + "enabled": true + } + ] +} +``` + +-> **Note**: the URL is wrapped over multiple lines to make it easier to read +without horizontal scrolling in the example above however this needs to be a +normal single-line string value in a JSON configuration file. + @@ -235,6 +285,9 @@ visible to Consul operators in the configuration file while UI users can query the metrics they need without separately obtaining a token for that provider or having a token exposed to them that they might be able to use elsewhere. + + + ```hcl ui_config { enabled = true @@ -251,6 +304,34 @@ ui_config { } ``` + + + +```json +{ + "ui_config": [ + { + "enabled": true, + "metrics_provider": "example-apm", + "metrics_proxy": [ + { + "add_headers": [ + { + "name": "Authorization", + "value": "Bearer \u003ctoken\u003e" + } + ], + "base_url": "https://example-apm.com/api/v1/metrics" + } + ] + } + ] +} +``` + + + + ## Custom Metrics Providers Consul 1.9.0 includes a built-in provider for fetching metrics from @@ -484,6 +565,9 @@ named `example-provider`, which is defined in have been specified in the call to `consul.registerMetricsProvider` as in the code listing in the last section. + + + ```hcl ui_config { enabled = true @@ -497,6 +581,23 @@ ui_config { } ``` + + + +```json +{ + "ui_config": { + "enabled": true, + "metrics_provider": "example-provider", + "metrics_provide_files": ["/usr/local/bin/example-metrics-provider.js"], + "metrics_provider_options_json": "{\"foo\":\"bar\"}" + } +} +``` + + + + More than one JavaScript file may be specified in [`metrics_provider_files`](/docs/agent/options#ui_config_metrics_provider_files) and all we be served allowing flexibility if needed to include dependencies. From 65d750a84d0702d0ae8c07fc183eab511455ae8e Mon Sep 17 00:00:00 2001 From: Krastin Krastev Date: Mon, 24 Jan 2022 16:10:03 +0100 Subject: [PATCH 2/3] migrating to in /docs/connect/observability/ui-visualization --- .../observability/ui-visualization.mdx | 80 ++++++++----------- 1 file changed, 33 insertions(+), 47 deletions(-) diff --git a/website/content/docs/connect/observability/ui-visualization.mdx b/website/content/docs/connect/observability/ui-visualization.mdx index 9a9056ff07..63768ff6b8 100644 --- a/website/content/docs/connect/observability/ui-visualization.mdx +++ b/website/content/docs/connect/observability/ui-visualization.mdx @@ -66,8 +66,7 @@ service named `prometheus-server` so each Consul agent can reach it on A full configuration to enable Prometheus is given below. - - + ```hcl ui_config { @@ -79,9 +78,6 @@ ui_config { } ``` - - - ```json { "ui_config": [ @@ -98,8 +94,7 @@ ui_config { } ``` - - + Similarly, to configure the UI on Kubernetes, use this [reference](/docs/k8s/connect/observability/metrics). @@ -120,27 +115,22 @@ to the relevant information. An example with Grafana is shown below. - - + + + ```hcl ui_config { enabled = true dashboard_url_templates { - service = "https://grafana.example.com/d/lDlaj-NGz/ - service-overview?orgId=1&var-service={{Service.Name}}& - var-namespace={{Service.Namespace}}& - var-partition={{Service.Partition}}&var-dc={{Datacenter}}" + service = "https://grafana.example.com/d/lDlaj-NGz/service-overview?orgId=1&var-service={{Service.Name}}&var-namespace={{Service.Namespace}}&var-partition={{Service.Partition}}&var-dc={{Datacenter}}" } } ``` --> **Note**: the URL is wrapped over multiple lines to make it easier to read -without horizontal scrolling in the example above however this needs to be a -normal single-line string value in an HCL configuration file. + - - + ```json { @@ -148,10 +138,7 @@ normal single-line string value in an HCL configuration file. { "dashboard_url_templates": [ { - "service": "https://grafana.example.com/d/lDlaj-NGz/ - service-overview?orgId=1\u0026var-service={{Service.Name}}\u0026 - var-namespace={{Service.Namespace}}\u0026 - var-partition={{Service.Partition}}\u0026var-dc={{Datacenter}}" + "service": "https://grafana.example.com/d/lDlaj-NGz/service-overview?orgId=1\u0026var-service={{Service.Name}}\u0026var-namespace={{Service.Namespace}}\u0026var-partition={{Service.Partition}}\u0026var-dc={{Datacenter}}" } ], "enabled": true @@ -160,17 +147,19 @@ normal single-line string value in an HCL configuration file. } ``` --> **Note**: the URL is wrapped over multiple lines to make it easier to read -without horizontal scrolling in the example above however this needs to be a -normal single-line string value in a JSON configuration file. + - - - -On Kubernetes, Consul Server configuration is set in your Helm config via the -[`server.extraConfig`](/docs/k8s/helm#v-server-extraconfig) key as JSON: + ```yaml +################################### Notes: #################################### +# On Kubernetes, Consul Server configuration is set in your Helm config via # +# the server.extraConfig key as JSON. # +# # +# The `{{` characters in the URL must be escaped using `{{ "{{" }}` so that # +# Helm doesn't try to template them. # +############################################################################### + # The UI is enabled by default so this stanza is not required. ui: enabled: true @@ -185,10 +174,9 @@ server: } ``` --> **Note**: The `{{` characters in the URL must be escaped using `{{ "{{" }}` so that Helm doesn't try to template them. + - - + ![Consul UI Service Dashboard Link](/img/ui-dashboard-url-template.png) @@ -221,6 +209,8 @@ un-authenticated workloads on the network**. With ACLs enabled, the proxy endpoint requires a valid token with read access to all nodes and services (across all namespaces in Enterprise): + + ```hcl # Consul OSS service_prefix "" { @@ -241,6 +231,8 @@ namespace_prefix "" { } ``` + + It's typical for most authenticated users to have this level of access in Consul as it's required for viewing the catalog or discovering services. If you use a [Single Sign-On integration](/docs/security/acl/auth-methods/oidc) (Consul @@ -285,8 +277,7 @@ visible to Consul operators in the configuration file while UI users can query the metrics they need without separately obtaining a token for that provider or having a token exposed to them that they might be able to use elsewhere. - - + ```hcl ui_config { @@ -304,9 +295,6 @@ ui_config { } ``` - - - ```json { "ui_config": [ @@ -329,8 +317,7 @@ ui_config { } ``` - - + ## Custom Metrics Providers @@ -347,6 +334,8 @@ feedback on [GitHub](https://github.com/hashicorp/consul) or The template for a complete provider JavaScript file is given below. + + ```JavaScript (function () { var provider = { @@ -553,6 +542,8 @@ The template for a complete provider JavaScript file is given below. }()); ``` + + Additionally, the built in [Prometheus provider code](https://github.com/hashicorp/consul/blob/main/ui/packages/consul-ui/vendor/metrics-providers/prometheus.js) can be used as a reference. @@ -565,8 +556,7 @@ named `example-provider`, which is defined in have been specified in the call to `consul.registerMetricsProvider` as in the code listing in the last section. - - + ```hcl ui_config { @@ -581,9 +571,6 @@ ui_config { } ``` - - - ```json { "ui_config": { @@ -595,8 +582,7 @@ ui_config { } ``` - - + More than one JavaScript file may be specified in [`metrics_provider_files`](/docs/agent/options#ui_config_metrics_provider_files) From 8abf4088c12b3041bdb07ee4e3ba56a4f30257c1 Mon Sep 17 00:00:00 2001 From: Krastin Krastev Date: Mon, 24 Jan 2022 16:35:18 +0100 Subject: [PATCH 3/3] fixing K8s notes placement in /docs/connect/observability/ui-visualization --- .../docs/connect/observability/ui-visualization.mdx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/website/content/docs/connect/observability/ui-visualization.mdx b/website/content/docs/connect/observability/ui-visualization.mdx index 63768ff6b8..4c222e010d 100644 --- a/website/content/docs/connect/observability/ui-visualization.mdx +++ b/website/content/docs/connect/observability/ui-visualization.mdx @@ -152,14 +152,6 @@ ui_config { ```yaml -################################### Notes: #################################### -# On Kubernetes, Consul Server configuration is set in your Helm config via # -# the server.extraConfig key as JSON. # -# # -# The `{{` characters in the URL must be escaped using `{{ "{{" }}` so that # -# Helm doesn't try to template them. # -############################################################################### - # The UI is enabled by default so this stanza is not required. ui: enabled: true @@ -178,6 +170,11 @@ server: +~> **Note**: On Kubernetes, Consul Server configuration is set in your Helm +config via the [`server.extraConfig`](/docs/k8s/helm#v-server-extraconfig) key as JSON. +The `{{` characters in the URL must be escaped using `{{ "{{" }}` so that Helm +doesn't try to template them. + ![Consul UI Service Dashboard Link](/img/ui-dashboard-url-template.png) ### Metrics Proxy