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

Update and lint Discovery topics second group #2426

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
106 changes: 55 additions & 51 deletions docs/sources/reference/components/discovery/discovery.ec2.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ title: discovery.ec2

# discovery.ec2

`discovery.ec2` lets you retrieve scrape targets from EC2 instances. The private IP address is used by default, but you can change it to the public IP address using relabeling.
`discovery.ec2` lets you retrieve scrape targets from EC2 instances.
The private IP address is used by default, but you can change it to the public IP address using relabeling.

The IAM credentials used must have the `ec2:DescribeInstances` permission to discover scrape targets, and may optionally have the `ec2:DescribeAvailabilityZones` permission to make the availability zone ID available as a label.

## Usage

```alloy
discovery.ec2 "LABEL" {
discovery.ec2 "<LABEL>" {
}
```

Expand All @@ -25,64 +26,64 @@ The following arguments are supported:

Name | Type | Description | Default | Required
-------------------------|---------------------|-------------------------------------------------------------------------------------------------------------------------|---------|---------
`endpoint` | `string` | Custom endpoint to be used. | | no
`region` | `string` | The AWS region. If blank, the region from the instance metadata is used. | | no
`access_key` | `string` | The AWS API key ID. If blank, the environment variable `AWS_ACCESS_KEY_ID` is used. | | no
`secret_key` | `string` | The AWS API key secret. If blank, the environment variable `AWS_SECRET_ACCESS_KEY` is used. | | no
`profile` | `string` | Named AWS profile used to connect to the API. | | no
`role_arn` | `string` | AWS Role Amazon Resource Name (ARN), an alternative to using AWS API keys. | | no
`refresh_interval` | `string` | Refresh interval to re-read the instance list. | 60s | no
`port` | `int` | The port to scrape metrics from. If using the public IP address, this must instead be specified in the relabeling rule. | 80 | no
`bearer_token_file` | `string` | File containing a bearer token to authenticate with. | | no
`bearer_token` | `secret` | Bearer token to authenticate with. | | no
`enable_http2` | `bool` | Whether HTTP2 is supported for requests. | `true` | no
`endpoint` | `string` | Custom endpoint to be used. | | no
`follow_redirects` | `bool` | Whether redirects returned by the server should be followed. | `true` | no
`proxy_url` | `string` | HTTP proxy to send requests through. | | no
`no_proxy` | `string` | Comma-separated list of IP addresses, CIDR notations, and domain names to exclude from proxying. | | no
`proxy_from_environment` | `bool` | Use the proxy URL indicated by environment variables. | `false` | no
`port` | `int` | The port to scrape metrics from. If using the public IP address, this must instead be specified in the relabeling rule. | 80 | no
`profile` | `string` | Named AWS profile used to connect to the API. | | no
`proxy_connect_header` | `map(list(secret))` | Specifies headers to send to proxies during CONNECT requests. | | no
`proxy_from_environment` | `bool` | Use the proxy URL indicated by environment variables. | `false` | no
`proxy_url` | `string` | HTTP proxy to send requests through. | | no
`refresh_interval` | `string` | Refresh interval to re-read the instance list. | 60s | no
`region` | `string` | The AWS region. If blank, the region from the instance metadata is used. | | no
`role_arn` | `string` | AWS Role Amazon Resource Name (ARN), an alternative to using AWS API keys. | | no
`secret_key` | `string` | The AWS API key secret. If blank, the environment variable `AWS_SECRET_ACCESS_KEY` is used. | | no

At most, one of the following can be provided:
- [`bearer_token` argument](#arguments).
- [`bearer_token_file` argument](#arguments).
- [`basic_auth` block][basic_auth].
- [`authorization` block][authorization].
- [`oauth2` block][oauth2].

* [`authorization` block][authorization].
* [`basic_auth` block][basic_auth].
* [`bearer_token_file` argument](#arguments).
* [`bearer_token` argument](#arguments).
* [`oauth2` block][oauth2].

{{< docs/shared lookup="reference/components/http-client-proxy-config-description.md" source="alloy" version="<ALLOY_VERSION>" >}}

## Blocks

The following blocks are supported inside the definition of
`discovery.ec2`:
The following blocks are supported inside the definition of `discovery.ec2`:

Hierarchy | Block | Description | Required
--------------------|-------------------|----------------------------------------------------------|---------
basic_auth | [basic_auth][] | Configure basic_auth for authenticating to the endpoint. | no
authorization | [authorization][] | Configure generic authorization to the endpoint. | no
filter | [filter][] | Filters discoverable resources. | no
oauth2 | [oauth2][] | Configure OAuth2 for authenticating to the endpoint. | no
oauth2 > tls_config | [tls_config][] | Configure TLS settings for connecting to the endpoint. | no
tls_config | [tls_config][] | Configure TLS settings for connecting to the endpoint. | no
Hierarchy | Block | Description | Required
--------------------|-------------------|------------------------------------------------------------|---------
authorization | [authorization][] | Configure generic authorization to the endpoint. | no
basic_auth | [basic_auth][] | Configure `basic_auth` for authenticating to the endpoint. | no
filter | [filter][] | Filters discoverable resources. | no
oauth2 | [oauth2][] | Configure OAuth2 for authenticating to the endpoint. | no
oauth2 > tls_config | [tls_config][] | Configure TLS settings for connecting to the endpoint. | no
tls_config | [tls_config][] | Configure TLS settings for connecting to the endpoint. | no

[filter]: #filter-block
[authorization]: #authorization-block
[oauth2]: #oauth2-block
[tls_config]: #tls_config-block
[basic_auth]: #basic_auth-block
[authorization]: #authorization
[basic_auth]: #basic_auth
[filter]: #filter
[oauth2]: #oauth2
[tls_config]: #tls_config

### basic_auth block
### authorization

{{< docs/shared lookup="reference/components/basic-auth-block.md" source="alloy" version="<ALLOY_VERSION>" >}}
{{< docs/shared lookup="reference/components/authorization-block.md" source="alloy" version="<ALLOY_VERSION>" >}}

### authorization block
### basic_auth

{{< docs/shared lookup="reference/components/authorization-block.md" source="alloy" version="<ALLOY_VERSION>" >}}
{{< docs/shared lookup="reference/components/basic-auth-block.md" source="alloy" version="<ALLOY_VERSION>" >}}

### filter block
### filter

Filters can be used optionally to filter the instance list by other criteria.
Available filter criteria can be found in the [Amazon EC2 documentation](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html).
You can use filters to filter the instance list by other criteria.
Refer to the [Amazon EC2 documentation][amazon] for more information about filters.

Name | Type | Description | Default | Required
---------|----------------|-------------------------------|---------|---------
Expand All @@ -91,30 +92,31 @@ Name | Type | Description | Default | Required

Refer to the [Filter API AWS EC2 documentation][filter api] for the list of supported filters and their descriptions.

[amazon]: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html
[filter api]: https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_Filter.html

### oauth2 block
### oauth2

{{< docs/shared lookup="reference/components/oauth2-block.md" source="alloy" version="<ALLOY_VERSION>" >}}

### tls_config block
### tls_config

{{< docs/shared lookup="reference/components/tls-config-block.md" source="alloy" version="<ALLOY_VERSION>" >}}

## Exported fields

The following fields are exported and can be referenced by other components:

Name | Type | Description
---- | ---- | -----------
Name | Type | Description
----------|---------------------|-----------------------------------
`targets` | `list(map(string))` | The set of discovered EC2 targets.

Each target includes the following labels:

* `__meta_ec2_ami`: The EC2 Amazon Machine Image.
* `__meta_ec2_architecture`: The architecture of the instance.
* `__meta_ec2_availability_zone_id`: The availability zone ID in which the instance is running. Requires `ec2:DescribeAvailabilityZones`.
* `__meta_ec2_availability_zone`: The availability zone in which the instance is running.
* `__meta_ec2_availability_zone_id`: The availability zone ID in which the instance is running (requires `ec2:DescribeAvailabilityZones`).
* `__meta_ec2_instance_id`: The EC2 instance ID.
* `__meta_ec2_instance_lifecycle`: The lifecycle of the EC2 instance, set only for 'spot' or 'scheduled' instances, absent otherwise.
* `__meta_ec2_instance_state`: The state of the EC2 instance.
Expand All @@ -139,11 +141,11 @@ In those cases, exported fields retain their last healthy values.

## Debug information

`discovery.ec2` does not expose any component-specific debug information.
`discovery.ec2` doesn't expose any component-specific debug information.

## Debug metrics

`discovery.ec2` does not expose any component-specific debug metrics.
`discovery.ec2` doesn't expose any component-specific debug metrics.

## Example

Expand All @@ -159,19 +161,21 @@ prometheus.scrape "demo" {

prometheus.remote_write "demo" {
endpoint {
url = PROMETHEUS_REMOTE_WRITE_URL
url = <PROMETHEUS_REMOTE_WRITE_URL>

basic_auth {
username = USERNAME
password = PASSWORD
username = <USERNAME>
password = <PASSWORD>
}
}
}
```

Replace the following:
- `PROMETHEUS_REMOTE_WRITE_URL`: The URL of the Prometheus remote_write-compatible server to send metrics to.
- `USERNAME`: The username to use for authentication to the remote_write API.
- `PASSWORD`: The password to use for authentication to the remote_write API.

* _`<PROMETHEUS_REMOTE_WRITE_URL>`_: The URL of the Prometheus remote_write-compatible server to send metrics to.
* _`<USERNAME>`_: The username to use for authentication to the `remote_write` API.
* _`<PASSWORD>`_: The password to use for authentication to the `remote_write` API.

<!-- START GENERATED COMPATIBLE COMPONENTS -->

Expand Down
Loading
Loading