-
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.
added how to export metrics to prometheus docs
- Loading branch information
Showing
11 changed files
with
446 additions
and
183 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
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,52 @@ | ||
# Agent configuration | ||
|
||
The agent configuration allows you to customize various parameters for the behavior of the agent. Below is an example file illustrating the structure and available fields for configuring the agent: | ||
> Note: | ||
> You can configure the agent both from the command line interface and from a configuration file. | ||
### CLI Usage | ||
To start the loadbot agent, use the following command: | ||
|
||
Usage: | ||
loadbot start-agent [flags] | ||
|
||
Flags: | ||
-f, --config-file string Config file for loadbot-agent | ||
-h, --help help for start-agent | ||
--metrics_export_interval_seconds uint Prometheus export push interval | ||
--metrics_export_port string Expose metrics on port instead pushing to prometheus | ||
--metrics_export_url string Prometheus export url used for pushing metrics | ||
-n, --name string Agent name | ||
-p, --port string Agent port | ||
--stdin Provide configuration from stdin. | ||
|
||
> Note: | ||
> Configurations specified from the command line interface will overwrite those from the configuration file. | ||
### Configuration file | ||
|
||
In the configuration file, you're able to configure both workloads and the agent, whereas via the command-line interface, you can solely configure the agent. | ||
|
||
```json | ||
{ | ||
"agent": { | ||
"name": "mongo 6.0.8 workload", | ||
"port": "1234", | ||
"metrics_export_url": "http://victoria-metrics:8428/api/v1/import/prometheus", | ||
"metrics_export_interval_seconds": 10, | ||
"metrics_export_port": "9090", | ||
} | ||
} | ||
``` | ||
|
||
> Note: | ||
> The agent configuration is only applied when the agent is started. It cannot be changed at runtime using commands such as `loadbot config`. | ||
### Agent Fields | ||
- **name** (string, optional): Specifies the name of the agent. This field is used as a label in the metrics exporter. Useful when exporting metrics from multiple agents. | ||
- **port** (string, optional): Specifies the port on which the agent listens for incoming connections. | ||
- **metrics_export_url** (string, optional): If set, metrics will be pushed to the specified endpoint in the Prometheus standard format. | ||
- **metrics_export_interval_seconds** (integer, optional): Specifies the interval (in seconds) at which metrics are pushed to the export endpoint. | ||
- **metrics_export_port** (string, optional): If set, metrics will be accessible on the provided port. | ||
|
||
|
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,61 @@ | ||
The metrics exporting feature enables you to monitor and analyze various metrics related to your workload. Below, we detail the key aspects of this feature: | ||
|
||
### Library Dependency | ||
Our project utilizes the lightweight library [github.com/VictoriaMetrics/metrics](https://github.com/VictoriaMetrics/metrics) as an alternative to [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang). This library facilitates efficient handling and exporting of metrics for monitoring purposes. | ||
|
||
### Exporting Strategies | ||
You have the flexibility to choose between two strategies for exporting metrics: pull or push. | ||
|
||
#### Push Strategy: | ||
|
||
With this strategy, the tool pushes metrics to the provided URL at the specified interval. | ||
|
||
Configure the [agent](/loadbot/setup/agent/) using the following flags: | ||
|
||
- **metrics_export_url**: Specifies the URL where metrics will be pushed. | ||
- **metrics_export_interval_seconds**: Defines the interval (in seconds) for pushing metrics. | ||
|
||
#### Pull Strategy: | ||
With this strategy, external app pull metrics from us and put them into Prometheus. | ||
|
||
Configure the [agent](/loadbot/setup/agent/) using the following flags: | ||
- **metrics_export_url**: Configure the agent to expose an HTTP server on the provided port. | ||
|
||
|
||
### Metrics Selection | ||
|
||
The metrics available for monitoring encompass both system-level metrics and custom metrics related to your workloads. Here are some popular metrics from a Go application's perspective: | ||
|
||
System Metrics: | ||
|
||
- `go_goroutines` | ||
- `go_threads` | ||
- `go_memstats_alloc_bytes` | ||
- `go_memstats_heap_inuse_bytes` | ||
- `go_memstats_alloc_bytes_total` | ||
- `process_resident_memory_bytes` | ||
|
||
Custom Workload Metrics: | ||
|
||
- `requests_total` | ||
- `requests_error` | ||
- `requests_duration_seconds (histogram)` | ||
|
||
#### Labels for Querying | ||
When querying metrics, you can utilize labels to specify job-related information: | ||
|
||
``` | ||
{job="job_name_here", job_uuid="auto_generate_uuid", agent="agent_name_here"} | ||
``` | ||
|
||
Example query: | ||
``` | ||
requests_total{job="workload 1", agent="186.12.9.19"} | ||
``` | ||
|
||
The `job_uuid` label distinguishes between different job runs/attempts, allowing you to track and analyze performance across multiple executions of the same job. Additionally, all metrics are labeled with the `name of the agent`, enabling you to differentiate metrics coming from different agents. | ||
|
||
### Additional Resources | ||
Metrics have been extracted from VictoriaMetrics sources. For more in-depth information about VictoriaMetrics, you can refer to the following article: [VictoriaMetrics: Creating the Best Remote Storage for Prometheus](https://faun.pub/victoriametrics-creating-the-best-remote-storage-for-prometheus-5d92d66787ac). | ||
|
||
You can also refer to an excellent article discussing Prometheus metrics in Go, which can provide further insights (Prometheus Go Metrics)[https://povilasv.me/prometheus-go-metrics/]. |
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
Oops, something went wrong.