Skip to content

[AutoOps] Allow AUTOOPS_ES_ prefix for environment variables#46358

Merged
pickypg merged 2 commits into
mainfrom
autoops/add-autoops-es-env
Sep 3, 2025
Merged

[AutoOps] Allow AUTOOPS_ES_ prefix for environment variables#46358
pickypg merged 2 commits into
mainfrom
autoops/add-autoops-es-env

Conversation

@pickypg
Copy link
Copy Markdown
Member

@pickypg pickypg commented Sep 3, 2025

This adds support for three expected environment variables to be supplied by service usage of AutoOps wrapping the Elasticsearch metricset.

This adds support for these in addition to the existing key

  • AUTOOPS_ES_USERNAME (or ELASTICSEARCH_READ_USERNAME)
  • AUTOOPS_ES_PASSWORD (or ELASTICSEARCH_READ_PASSWORD)
  • AUTOOPS_ES_API_KEY (or ELASTICSEARCH_API_KEY)

This also adds support for the API Key to be supplied as a Base64 encoded value, which will be used directly. This is detected by looking for the : that separates the existing id:key value, then encoding it if it detects that and, otherwise, using it directly.

Proposed commit message

Add expected support for AUTOOPS_ES_USERNAME, AUTOOPS_ES_PASSWORD, and AUTOOPS_ES_API_KEY. Support base64-encoded API Keys without re-encoding them.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Disruptive User Impact

None. This retains backward compatibility while expanding compatibility.

How to test this PR locally

Attempt to use the environment variables specified to connect to Elasticsearch. When using the API Key, try to use both the Base64-encoded value and the non-Base64 encoded value.

Related issues

Use cases

Allow users to copy/paste the API Key that is provided in most scenarios (Base64 encoded) and allow AutoOps to specify more appropriately named environment variables.

This adds support for three expected environment variables to be
supplied by service usage of AutoOps wrapping the Elasticsearch
metricset.

This adds support for these in addition to the existing key

- `AUTOOPS_ES_USERNAME` (or `ELASTICSEARCH_READ_USERNAME`)
- `AUTOOPS_ES_PASSWORD` (or `ELASTICSEARCH_READ_PASSWORD`)
- `AUTOOPS_ES_API_KEY` (or `ELASTICSEARCH_API_KEY`)

This also adds support for the API Key to be supplied as a Base64
encoded value, which will be used directly. This is detected by
looking for the `:` that separates the existing `id:key` value,
then encoding it if it detects that and, otherwise, using it
directly.
@pickypg pickypg requested a review from a team September 3, 2025 03:47
@pickypg pickypg self-assigned this Sep 3, 2025
@pickypg pickypg requested review from a team as code owners September 3, 2025 03:47
@pickypg pickypg added bug release-note:skip The PR should be ignored when processing the changelog backport-9.1 Automated backport to the 9.1 branch labels Sep 3, 2025
@botelastic botelastic Bot added the needs_team Indicates that the issue/PR needs a Team:* label label Sep 3, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 3, 2025

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@pickypg pickypg added Team:Monitoring Stack Monitoring team Team:Opex labels Sep 3, 2025
@botelastic botelastic Bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Sep 3, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 3, 2025

🔍 Preview links for changed docs

@pickypg pickypg enabled auto-merge (squash) September 3, 2025 03:49
@pickypg pickypg merged commit b0f8ee7 into main Sep 3, 2025
50 checks passed
@pickypg pickypg deleted the autoops/add-autoops-es-env branch September 3, 2025 15:08
mergify Bot pushed a commit that referenced this pull request Sep 3, 2025
This adds support for three expected environment variables to be
supplied by service usage of AutoOps wrapping the Elasticsearch
metricset.

This adds support for these in addition to the existing key

- `AUTOOPS_ES_USERNAME` (or `ELASTICSEARCH_READ_USERNAME`)
- `AUTOOPS_ES_PASSWORD` (or `ELASTICSEARCH_READ_PASSWORD`)
- `AUTOOPS_ES_API_KEY` (or `ELASTICSEARCH_API_KEY`)

This also adds support for the API Key to be supplied as a Base64
encoded value, which will be used directly. This is detected by
looking for the `:` that separates the existing `id:key` value,
then encoding it if it detects that and, otherwise, using it
directly.

(cherry picked from commit b0f8ee7)
pickypg added a commit that referenced this pull request Sep 3, 2025
… (#46369)

This adds support for three expected environment variables to be
supplied by service usage of AutoOps wrapping the Elasticsearch
metricset.

This adds support for these in addition to the existing key

- `AUTOOPS_ES_USERNAME` (or `ELASTICSEARCH_READ_USERNAME`)
- `AUTOOPS_ES_PASSWORD` (or `ELASTICSEARCH_READ_PASSWORD`)
- `AUTOOPS_ES_API_KEY` (or `ELASTICSEARCH_API_KEY`)

This also adds support for the API Key to be supplied as a Base64
encoded value, which will be used directly. This is detected by
looking for the `:` that separates the existing `id:key` value,
then encoding it if it detects that and, otherwise, using it
directly.

(cherry picked from commit b0f8ee7)

Co-authored-by: Chris Earle <pickypg@users.noreply.github.com>
pickypg added a commit to elastic/autoops-install that referenced this pull request Sep 22, 2025
This also updates the internally used environment variables from
`ELASTICSEARCH_READ_*` to `AUTOOPS_ES_*`, which relates to
elastic/beats#46358.
pickypg added a commit to elastic/docs-content that referenced this pull request Sep 24, 2025
The `ELASTICSEARCH_READ_*` keys continue to work, but it was decided to
add more explicit AutoOps-related key names and they are now being used
by the wizard.

Relates to elastic/beats#46358
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-9.1 Automated backport to the 9.1 branch bug release-note:skip The PR should be ignored when processing the changelog Team:Monitoring Stack Monitoring team Team:Opex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Elasticsearch] Simplify API Key Specification

2 participants