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

HAproxy with Otel #179

Closed
wants to merge 3 commits into from
Closed
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
104 changes: 61 additions & 43 deletions docs/shipping/Load-Balancer/haproxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,64 +107,82 @@ If you don't see your logs, see [log shipping troubleshooting]({{site.baseurl}}/

## Metrics

To send your Prometheus-format HAProxy metrics to Logz.io, you need to add the **inputs.haproxy** and **outputs.http** plug-ins to your Telegraf configuration file.
To send your Prometheus-format HAProxy metrics to Logz.io, you need configure the OpenTelemetry collector to send your collected Prometheus-format HAproxy metrics to Logz.io.

### Configure Telegraf to send your metrics data to Logz.io
#### Configuring OpenTelemetry to send your metrics data to Logz.io


##### Download OpenTelemetry collector

:::note
If you already have OpenTelemetry, proceed to the next step.
:::

#### Set up Telegraf v1.17 or higher
Create a dedicated directory on your host and download the [OpenTelemetry collector](https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.60.0) that is relevant to the operating system of your host.

After downloading the collector, create a configuration file `config.yaml`.

##### Configure the receivers

Open the configuration file and make sure that it states the receivers required for your source.

```yaml
receivers:
prometheus:
config:
scrape_configs:
- job_name: 'haproxy'
static_configs:
- targets: ['localhost:1936']
labels:
instance: 'haproxy_instance'
metrics_path: '/haproxy?stats;csv'
basic_auth:
username: 'your_username'
password: 'your_password'
```

{@include: ../../_include/metric-shipping/telegraf-setup.md}

#### Add the inputs.haproxy plug-in
Adjust the `targets`, `username`, and `password` as per your HAProxy setup.

First you need to configure the input plug-in to enable Telegraf to scrape the HAProxy data from your hosts. To do this, add the following code to the configuration file:
##### Configure the exporters

In the same configuration file, add the following to the `exporters` section:

```yaml
exporters:
prometheusremotewrite:
endpoint: https://<<LISTENER-HOST>>:8053
headers:
Authorization: Bearer <<PROMETHEUS-METRICS-SHIPPING-TOKEN>>
```

{@include: ../../_include/general-shipping/replace-placeholders-prometheus.html}

``` ini
[[inputs.haproxy]]
## An array of address to gather stats about. Specify an ip on hostname
## with optional port. ie localhost, 10.10.3.33:1936, etc.
## Make sure you specify the complete path to the stats endpoint
## including the protocol, ie http://10.10.3.33:1936/haproxy?stats
##### Configure the service pipeline

In the `service` section of the configuration file, add the following configuration

```yaml
service:
pipelines:
metrics:
receivers: [<<YOUR-RECEIVER>>]
exporters: [prometheusremotewrite]
```
* Replace `<<YOUR_RECEIVER>>` with the name of your receiver.

## Credentials for basic HTTP authentication
# username = "admin"
# password = "admin"

## If no servers are specified, then default to 127.0.0.1:1936/haproxy?stats
servers = ["http://myhaproxy.com:1936/haproxy?stats"]

## You can also use local socket with standard wildcard globbing.
## Server address not starting with 'http' will be treated as a possible
## socket, so both examples below are valid.
# servers = ["socket:/run/haproxy/admin.sock", "/run/haproxy/*.sock"]
##### Start the collector

## By default, some of the fields are renamed from what haproxy calls them.
## Setting this option to true results in the plugin keeping the original
## field names.
# keep_field_names = false
Run the following command:

## Optional TLS Config
# tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Use TLS but skip chain & host verification
# insecure_skip_verify = false
```shell
<path/to>/otelcol-contrib --config ./config.yaml
```

:::note
The database name is only required for instantiating a connection with the server and does not restrict the databases that we collect metrics from. The full list of data scraping and configuring options can be found [here](https://github.com/influxdata/telegraf/blob/release-1.18/plugins/inputs/haproxy/README.md).
:::


#### Add the outputs.http plug-in

{@include: ../../_include/metric-shipping/telegraf-outputs.md}
{@include: ../../_include/general-shipping/replace-placeholders-prometheus.html}
* Replace `<path/to>` with the path to the directory where you downloaded the collector. If the name of your configuration file is different to `config`, adjust name in the command accordingly.

### Check Logz.io for your metrics
##### Check Logz.io for your metrics

Give your data some time to get from your system to ours, then log in to your Logz.io Metrics account, and open [the Logz.io Metrics tab](https://app.logz.io/#/dashboard/metrics/).

Expand Down
2 changes: 1 addition & 1 deletion static/manifest.json

Large diffs are not rendered by default.