Skip to content

Commit

Permalink
remove irrelevant info from vis design (#404)
Browse files Browse the repository at this point in the history
> [!CAUTION]
> DO NOT merge yourself, this will be auto merged upon approval
  • Loading branch information
dyc3 authored Apr 17, 2024
1 parent 895053a commit 6e1eb00
Showing 1 changed file with 0 additions and 102 deletions.
102 changes: 0 additions & 102 deletions visualization-design.typ
Original file line number Diff line number Diff line change
Expand Up @@ -134,108 +134,6 @@ In order to achieve this, a new rust crate will be created to handle this discov
caption: "Sequence Diagram Explaining How Grafana Receives Data From Load Balancers"
) <Figure::visualization-balancer-datasource-sequence>

=== Collection and Aggregation

Data collection will be handled by Grafana with a custom datasource that allows serialized JSON data to be passed in to the panel and then into the associated React component.

Data gathered must also be aggregated, an example Grafana aggregation rule can be found below:

```json
{
"metric": "process_start_time_seconds",
"drop_labels": ["container", "instance", "namespace", "pod"],
"aggregations": ["sum:counter"],
"aggregation_interval": "60s",
}
```

More information on data aggregation rules in Grafana can be found here: #cite(<grafana-data-aggregation>).

=== Data Source Setup Instructions From Grafana Documentation

To pull metrics from Prometheus into a Grafana panel, Prometheus must first be added as a data source. This requires provisioning the data source:

```yaml
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
# Access mode - proxy (server in the UI) or direct (browser in the UI).
url: http://localhost:9090
jsonData:
httpMethod: POST
manageAlerts: true
prometheusType: Prometheus
prometheusVersion: 2.44.0
cacheLevel: 'High'
disableRecordingRules: false
incrementalQueryOverlapWindow: 10m
exemplarTraceIdDestinations:
# Field with internal link pointing to data source in Grafana.
# datasourceUid value can be anything, but it should be unique across all defined data source uids.
- datasourceUid: my_jaeger_uid
name: traceID
# Field with external link.
- name: traceID
url: 'http://localhost:3000/explore?orgId=1&left=%5B%22now-1h%22,%22now%22,%22Jaeger%22,%7B%22query%22:%22$${__value.raw}%22%7D%5D'
```

This is an example configuration for provisioning a Prometheus data source. Once this is done, Prometheus must be configured to scrape metrics from Grafana by editing the configuration file (`grafana.ini` or `custom.ini`):

```ini
# Metrics available at HTTP URL /metrics and /metrics/plugins/:pluginId
[metrics]
# Disable / Enable internal metrics
enabled = true
# Disable total stats (stat_totals_*) metrics to be generated
disable_total_stats = false
# basic_auth_username =
# basic_auth_password =
```

Setting a username and password is optional, only set if you want to require authorization to view the metrics endpoint. After the configuration file is edited as shown above and Grafana is restarted, the metrics should be accessible at http://localhost:3000/metrics.

Next, add the job to your `prometheus.yml` file. Example:

```yaml
- job_name: 'grafana_metrics'
scrape_interval: 15s
scrape_timeout: 5s
static_configs:
- targets: ['localhost:3000']
```

This example job instructs Prometheus to scrape from port 3000 every 15 seconds. After adding the job, restart Prometheus and it should appear on the targets tab.

Finally in Grafana, hover your mouse over the Configuration (gear) icon on the left sidebar and then click Data Sources. Select the Prometheus data source, and on the Dashboards tab, import the Grafana metrics dashboard. All scaped metrics should now be available.

=== Data Source Setup Instructions From Prometheus

To create a Prometheus data source in Grafana:

- Click on the "cogwheel" in the sidebar to open the Configuration menu.
- Click on "Data Sources".
- Click on "Add data source".
- Select "Prometheus" as the type.
- Set the appropriate Prometheus server URL (for example, http://localhost:9090/)
- Adjust other data source settings as desired (for example, choosing the right Access method).
- Click "Save & Test" to save the new data source.

To create a new Grafana graph:

- Click the graph title, then click "Edit".
- Under the "Metrics" tab, select your Prometheus data source (bottom right).
- Enter any Prometheus expression into the "Query" field, while using the "Metric" field to lookup metrics via autocompletion.
- To format the legend names of time series, use the "Legend format" input. For example, to show only the method and status labels of a returned query result separated by a dash, you could use the legend format string {{method}} - {{status}}.
- Tune other graph settings until you have a working graph.

== Development Schedule

#figure(
Expand Down

0 comments on commit 6e1eb00

Please sign in to comment.