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

Add hints based autodiscover part #2182

Merged
merged 3 commits into from
Sep 19, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ In addition, the Kubernetes metadata are being added to each event by default.


[discrete]
== Autodiscover target Pods
== Autodiscover targeted Pods

To set the target host dynamically only for a targeted Pod based on its labels, use a variable in the
{agent} policy to return path information from the provider:
Expand Down Expand Up @@ -331,6 +331,81 @@ The policy generated by this configuration looks like:
target: orchestrator
----

[discrete]
== Autodiscover targeted Pods using hints (Elastic Agent standalone mode)

Standalone Elastic Agent supports autodiscover based on hints from the provider.
The hints mechanism looks for hints in Kubernetes Pod annotations which have the prefix `co.elastic.hints`.
As soon as the container starts, Elastic Agent will check if it contains any hints and launch the proper config for it.
Hints tell Elastic Agent how to monitor the given container by using the proper integration.
This is the full list of supported hints:

[float]
===== `co.elastic.hints/package`

The package to use for monitoring.

[float]
===== `co.elastic.hints/data_stream`

(optional) The list of data_streams to enable. If not specified the default data_streams will be enabled using the
default values as specified in the respective package/integration.

If data_streams are specified, then hints can be defined per data_stream like `co.elastic.hints/key.period: 10m`,
otherwise the data_stream will use the top level hints (`co.elastic.hints/period: 10m`) in its configuration.

[float]
===== `co.elastic.hints/host`

The host to use for metrics retrieval.

[float]
===== `co.elastic.hints/metrics_path`

The path to retrieve the metrics from (/metrics by default).

[float]
===== `co.elastic.hints/period`

The time interval for metrics retrieval, ie: 10s

[float]
===== `co.elastic.hints/timeout`

Metrics retrieval timeout, default: 3s

[float]
===== `co.elastic.hints/username`

The username to use for authentication
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

username and password are required?
is it elasticsearch credentioals?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these are integrations variables. If it is Redis for example , it should be Redis creds

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, those are integration level settings. Keep in mind that most of them are taken directly from Beat's docs :) .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks more like a required credentials, not as an configuration of specific integration 😕
but, yes, I found the beats doc - https://www.elastic.co/guide/en/beats/metricbeat/current/configuration-autodiscover-hints.html#_co_elastic_metricsusername


[float]
===== `co.elastic.hints/password`

The password to use for authentication. It is recommended to retrieve this sensitive information from an ENV variable
and avoid placing passwords in plain text.

[float]
===== `co.elastic.hints/stream`

The stream to use for logs collection, ie stdout/stderr.

In any case if the specified package has no logs support a generic container's logs input will be used as a
fallback.

In order to enable hints one need to add the `hints.enabled: true` in the provider's configuration, ie:

[source,yaml]
----
providers:
kubernetes:
node: ${NODE_NAME}
hints.enabled: true
----

The available packages that are supported through hints can be found at
https://github.com/elastic/elastic-agent/tree/main/deploy/kubernetes/elastic-agent-standalone/templates.d

[discrete]
== Provider for Node resources

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,58 @@ the following configuration should be added as an extra input in the DaemonSet m
Refer to <<kubernetes-provider,dynamic inputs and Kubernetes provider>> for more information
about shaping dynamic inputs for autodiscovery.

[discrete]
== Autodiscover targeted Pods using hints

In order to achieve dynamic monitoring of Pods/containers, one can use hints. This can be achieved by properly
enabling hints for the `kubernetes` dynamic provider. For more information about this feature refer to
<<kubernetes-provider,dynamic inputs and Kubernetes provider>>.

In the standalone policy ensure that the feature is enabled:

In order to enable hints one need to add the `hints.enabled: true` in the provider's configuration, ie:

[source,yaml]
----
providers:
kubernetes:
node: ${NODE_NAME}
hints.enabled: true
----

Then ensure that the proper volumes and volumeMounts are added properly. These sections are already defined in the
provided kubernetes manifest, so it's only required to uncomment these sections.

[source,yaml]
----
volumeMounts:
- name: external-inputs
mountPath: /etc/elastic-agent/inputs.d
...
volumes:
- name: external-inputs
emptyDir: {}
...
----

Along with these sections an init container is required which is responsible for downloading the hints' templates.
The init container is already defined, so uncomment the respective section:

["source", "yaml", subs="attributes"]
----
initContainers:
- name: k8s-templates-downloader
image: busybox:1.28
command: ['sh']
args:
- -c
- >-
mkdir -p /etc/elastic-agent/inputs.d &&
wget -O - https://github.com/elastic/elastic-agent/archive/{branch}.tar.gz | tar xz -C /etc/elastic-agent/inputs.d --strip=5 "elastic-agent-main/deploy/kubernetes/elastic-agent-standalone/templates.d"
volumeMounts:
- name: external-inputs
mountPath: /etc/elastic-agent/inputs.d
----

[discrete]
== Deploying {agent} to collect cluster-level metrics in large clusters
Expand Down