Skip to content

Commit

Permalink
Expose scheme and bearer_token_file and set insecure_skip_verify to true
Browse files Browse the repository at this point in the history
Signed-off-by: Pete Wall <[email protected]>
  • Loading branch information
petewall committed Jan 14, 2025
1 parent 32aeea4 commit 86b20a7
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 38 deletions.
41 changes: 22 additions & 19 deletions modules/kubernetes/kube-state-metrics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ Handles scraping Grafana kube-state-metrics metrics.

### `kubernetes`

Handles discovery of kubernetes targets and exports them, this component does not perform any scraping at all and is not required to be used for kubernetes, as a custom service discovery and targets can be defined and passed to `kube-state-metrics.scrape`
Handles discovery of kubernetes targets and exports them, this component does not perform any scraping at all and is not
required to be used for kubernetes, as a custom service discovery and targets can be defined and passed to
`kube-state-metrics.scrape`

#### Arguments

| Name | Required | Default | Description |
| :---------------- | :------- | :---------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------- |
|:------------------|:---------|:------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------|
| `namespaces` | _no_ | `[]` | The namespaces to look for targets in, the default (`[]`) is all namespaces |
| `field_selectors` | _no_ | `[]` | The [field selectors](https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/) to use to find matching targets |
| `label_selectors` | _no_ | `["app.kubernetes.io/name=kube-state-metrics"]` | The [label selectors](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/) to use to find matching targets |
Expand All @@ -23,42 +25,43 @@ Handles discovery of kubernetes targets and exports them, this component does no
#### Exports

| Name | Type | Description |
| :------- | :------------------ | :------------------------- |
|:---------|:--------------------|:---------------------------|
| `output` | `list(map(string))` | List of discovered targets |

#### Labels

The following labels are automatically added to exported targets.

| Label | Description |
| :-------- | :---------------------------------------------------------------------------------------------------------------------------- |
| `service` | The name of the service the endpoint/pod is associated with, derived from the metadata label `__meta_kubernetes_service_name` |
| `source` | Constant value of `kubernetes`, denoting where the results came from, this can be useful for LBAC |
| Label | Description |
|:---------|:--------------------------------------------------------------------------------------------------|
| `source` | Constant value of `kubernetes`, denoting where the results came from, this can be useful for LBAC |

---

### `scrape`

#### Arguments

| Name | Required | Default | Description |
| :---------------- | :------- | :------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------- |
| `targets` | _yes_ | `list(map(string))` | List of targets to scrape |
| `forward_to` | _yes_ | `list(MetricsReceiver)` | Must be a where scraped should be forwarded to |
| `job_label` | _no_ | `integrations/kubernetes/kube-state-metrics` | The job label to add for all metrics |
| `keep_metrics` | _no_ | [see code](module.river#L228) | A regular expression of metrics to keep |
| `drop_metrics` | _no_ | [see code](module.river#L235) | A regular expression of metrics to drop |
| `scrape_interval` | _no_ | `60s` | How often to scrape metrics from the targets |
| `scrape_timeout` | _no_ | `10s` | How long before a scrape times out |
| `max_cache_size` | _no_ | `100000` | The maximum number of elements to hold in the relabeling cache. This should be at least 2x-5x your largest scrape target or samples appended rate. |
| `clustering` | _no_ | `false` | Whether or not [clustering](https://grafana.com/docs/kube-state-metrics/latest/flow/concepts/clustering/) should be enabled |
| Name | Required | Default | Description |
|:--------------------|:---------|:---------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------|
| `targets` | _yes_ | `list(map(string))` | List of targets to scrape |
| `forward_to` | _yes_ | `list(MetricsReceiver)` | Must be a where scraped should be forwarded to |
| `job_label` | _no_ | `integrations/kubernetes/kube-state-metrics` | The job label to add for all metrics |
| `keep_metrics` | _no_ | [see code](metrics.alloy#L164) | A regular expression of metrics to keep |
| `drop_metrics` | _no_ | [see code](metrics.alloy#L157) | A regular expression of metrics to drop |
| `scheme` | _no_ | `http` | The scheme to use when scraping metrics |
| `bearer_token_file` | _no_ | none | The bearer token file |
| `scrape_interval` | _no_ | `60s` | How often to scrape metrics from the targets |
| `scrape_timeout` | _no_ | `10s` | How long before a scrape times out |
| `max_cache_size` | _no_ | `100000` | The maximum number of elements to hold in the relabeling cache. This should be at least 2x-5x your largest scrape target or samples appended rate. |
| `clustering` | _no_ | `false` | Whether or not [clustering](https://grafana.com/docs/kube-state-metrics/latest/flow/concepts/clustering/) should be enabled |

#### Labels

The following labels are automatically added to exported targets.

| Label | Description |
| :---- | :--------------------------------------------- |
|:------|:-----------------------------------------------|
| `job` | Set to the value of `argument.job_label.value` |

---
Expand Down
16 changes: 16 additions & 0 deletions modules/kubernetes/kube-state-metrics/metrics.alloy
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ declare "scrape" {
optional = true
}

argument "scheme" {
comment = "The scheme to use when scraping metrics (default: http)"
optional = true
}

argument "bearer_token_file" {
comment = "The bearer token file (default: none)"
optional = true
}

argument "scrape_interval" {
comment = "How often to scrape metrics from the targets (default: 60s)"
optional = true
Expand Down Expand Up @@ -125,6 +135,12 @@ declare "scrape" {
scrape_interval = coalesce(argument.scrape_interval.value, "60s")
scrape_timeout = coalesce(argument.scrape_timeout.value, "10s")

scheme = coalesce(argument.scheme.value, "http")
bearer_token_file = coalesce(argument.bearer_token_file.value, "")
tls_config {
insecure_skip_verify = true
}

clustering {
enabled = coalesce(argument.clustering.value, false)
}
Expand Down
Loading

0 comments on commit 86b20a7

Please sign in to comment.