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

Initial docs for agent OTel mode #1095

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
58 changes: 58 additions & 0 deletions docs/en/ingest-management/commands.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ invoking the wrong binary.
* <<elastic-agent-help-command,help>>
* <<elastic-agent-inspect-command,inspect>>
* <<elastic-agent-install-command,install>>
* <<elastic-agent-otel-command,otel>> [technical preview]
* <<elastic-agent-restart-command,restart>>
* <<elastic-agent-run-command,run>>
* <<elastic-agent-status-command,status>>
Expand Down Expand Up @@ -834,6 +835,63 @@ elastic-agent install --url=https://fleet-server:8220 \
--certificate-authorities=/path/to/ca.crt
----

++++
<hr>
++++

[discrete]
[[elastic-agent-otel-command]]
== elastic-agent otel

preview::[]

Run {agent} as an <<otel-agent,OpenTelemetry Collector>>.

[discrete]
=== Synopsis

[source,shell]
----
elastic-agent otel [flags]
elastic-agent otel [command]
kilfoyle marked this conversation as resolved.
Show resolved Hide resolved
----

[discrete]
=== Available commands

`--validate`::
kilfoyle marked this conversation as resolved.
Show resolved Hide resolved
Validates the OpenTelemetry collector configuration without running the collector.

[discrete]
=== Flags

`--config --config=file:/path/to/first --config=file:path/to/second`::
kilfoyle marked this conversation as resolved.
Show resolved Hide resolved
Locations to the config file(s). Note that only a single location can be set per flag entry, for example `--config=file:/path/to/first --config=file:path/to/second`.

`--feature-gates flag`::
Comma-delimited list of feature gate identifiers. Prefix with `-` to disable the feature. Prefixing with `+` or no prefix will enable the feature.

`-h, --help`::
Get help for the `otel` sub-command. Use `elastic-agent otel [command] --help` for more information about a command.

`--set stringArray`::
kilfoyle marked this conversation as resolved.
Show resolved Hide resolved
Set an arbitrary component config property. The component has to be defined in the configuration file and the flag has a higher precedence. Array configuration properties are overridden and maps are joined. For example, `--set=processors.batch.timeout=2s`.
kilfoyle marked this conversation as resolved.
Show resolved Hide resolved

[discrete]
=== Examples

Run {agent} as on OTel Collector using the supplied `otel.yml` configuration file.
[source,shell]
----
./elastic-agent otel --config otel.yml
----

Change the default verbosity setting in the {agent} OTel configuration from `detailed` to `normal`.

[source,shell]
----
./elastic-agent otel --config otel.yml --set "exporters::debug::verbosity=normal"
----

++++
<hr>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[[otel-agent-configuration]]
= {agent} OTel configuration

preview::[]

When running in `otel` mode, {agent} supports a standard OTel Collector configuration.
andrzej-stencel marked this conversation as resolved.
Show resolved Hide resolved

You can provide the OTel configuration to {agent} using any of the following four schemes:

* `file` - The configuration is read from a file. For example, `file:path/to/config.yaml`.
* `env` - The configuration is read from an environment variable. For example, `env:MY_CONFIG_IN_AN_ENVVAR`.
* `yaml` - The configuration is read from a standard YAML-formatted file. For example, `yaml:exporters::debug::verbosity: detailed`.
* `http` - The configuration is read from an HTTP URL. For example, `http://www.example.com`.
kilfoyle marked this conversation as resolved.
Show resolved Hide resolved
// Perhaps we can improve these examples to make them more clear. I'm not sure I understand what the configuration would look like when passed as a URL, for example.
kilfoyle marked this conversation as resolved.
Show resolved Hide resolved

To help you get started, when you download an {agent} install package, the package comes with a sample OTel configuration file, `otel.yml` located in the package base directory.
kilfoyle marked this conversation as resolved.
Show resolved Hide resolved

[source,shell]
----
receivers: <1>
filelog:
include: [ /var/log/system.log ]
start_at: beginning

processors: <2>
resource:
attributes:
- key: service.name
action: insert
value: elastic-otel-test

exporters: <3>
debug:
verbosity: detailed
sampling_initial: 10000
sampling_thereafter: 10000

service: <4>
pipelines:
logs:
receivers: [filelog]
processors: [resource]
exporters:
- debug
----

<1> link:https://opentelemetry.io/docs/collector/configuration/#receivers[Receivers] collect telemetry from one or more sources.
<2> link:https://opentelemetry.io/docs/collector/configuration/#processors[Processors] take the data collected by receivers and modify or transform it before sending it to the exporters.
<3> link:https://opentelemetry.io/docs/collector/configuration/#exporters[Exporters] send data to one or more backends or destinations.
<4> The link:https://opentelemetry.io/docs/collector/configuration/#connectors[Service] The section is used to configure what components are enabled in the Collector based on the configuration found in the receivers, processors, exporters, and extensions sections. If a component is configured, but not defined within the service section, then it's not enabled.
kilfoyle marked this conversation as resolved.
Show resolved Hide resolved

For full details about setting up this file, refer to link:https://opentelemetry.io/docs/collector/configuration/[Configuration] in the OpenTelemetry documentation.
145 changes: 145 additions & 0 deletions docs/en/ingest-management/elastic-agent/otel-agent.asciidoc
kilfoyle marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
[[otel-agent]]
= Run {agent} as an OTel Collector

preview::[]

The link:https://opentelemetry.io/docs/collector/[OpenTelemetry Collector] is a vendor-neutral way to receive, process, and export telemetry data. {agent} includes an embedded OTel Collector, enabling you to instrument your applications and infrastructure once, and send data to multiple vendors and backends.

When you run {agent} in `otel` mode it supports the standard OTel Collector configuration format that defines a set of receivers, processors, exporters, and connectors. Logs, metrics, and traces can be ingested using OpenTelemetry data formats.

The following steps will help you to get set up quickly using {agent} as an OTel Collector. Note that all steps are run with `sudo` as it's generally recommended to run {agent} with administrative privileges.
kilfoyle marked this conversation as resolved.
Show resolved Hide resolved

[discrete]
== Run {agent} in OTel mode

For simplicity, these steps demonstrate OTel mode using standalone {agent}. The install steps for {fleet}-managed {agent} are very similar. Refer to the <<elastic-agent-installation,Install {agents}>> section for the full set of requirements and steps for any install scenario.

. On your host, download and extract the {agent} installation package.
+
--
// tag::install-elastic-agent[]

include::{ingest-docs-root}/docs/en/ingest-management/tab-widgets/download-widget.asciidoc[]

// end::install-elastic-agent[]
--
+
The commands shown are for AMD platforms, but ARM packages are also available.
kilfoyle marked this conversation as resolved.
Show resolved Hide resolved
Refer to the {agent} https://www.elastic.co/downloads/elastic-agent[downloads page]
for the full list of available packages.

. Change into the agent package directory and run {agent} with the `otel` subcommand and the `-h` option to view the command syntax and available parameters:
+
[source,shell]
--
cd <agent-package-name>
sudo ./elastic-agent otel -h
--
+
TIP: You can also refer to the <<elastic-agent-otel-command,{agent} OTel>> command documentation for the full command syntax.

. View or update the OTel configuration file.
+
A basic OTel configuration file named `otel.yml` is included in the {agent} package. You can view or update it using any text editor.
+
[source,yaml]
--
receivers:
filelog:
include: [ /var/log/system.log ]
start_at: beginning

processors:
resource:
attributes:
kilfoyle marked this conversation as resolved.
Show resolved Hide resolved
- key: service.name
action: insert
value: elastic-otel-test

exporters:
debug:
verbosity: detailed
sampling_initial: 10000
kilfoyle marked this conversation as resolved.
Show resolved Hide resolved
sampling_thereafter: 10000

service:
pipelines:
logs:
receivers: [filelog]
processors: [resource]
exporters:
- debug%
--
+
By default, the default OTel configuration sets {agent} to:

* Read the contents of `/var/log/system.log`.
* Run a processor to insert `elastic-otel-test` into the output.
* Send the data with a `detailed` level of verbosity.
+
Refer to <<otel-agent-configuration>> to learn more about setting up this file.

. [Optional] Override a setting in the OTel configuration
+
You can use the `set` flag to manually override any setting defined in the OTel configuration file. For example, run the following command to change the default verbosity setting from `detailed` to `normal`.
+
[source,shell]
----
sudo ./elastic-agent otel --config otel.yml --set "exporters::debug::verbosity=normal"
kilfoyle marked this conversation as resolved.
Show resolved Hide resolved
----

. Validate the configuration
+
To validate the OTel configuration for your {agent}, run the `otel` command with the `validate` option and the path to the config file:
+
[source,shell]
--
sudo ./elastic-agent otel validate --config otel.yml
--
+
If no error is returned, the configuration file is determined to be valid.

. Run {agent}
+
Now, run {agent} with OTel mode configured:
+
[source,shell]
--
sudo ./elastic-agent otel --config otel.yml
--
+
You should see a response indicating that {agent} has started successfully in OTel mode:
+
[source,shell]
--
Starting in otel mode
2024-05-31T12:39:43.047-0400 info [email protected]/telemetry.go:59 Setting up own telemetry...
2024-05-31T12:39:43.049-0400 info [email protected]/telemetry.go:104 Serving metrics {"address": ":8888", "level": "Basic"}
2024-05-31T12:39:43.052-0400 info [email protected]/exporter.go:275 Development component. May change in the future. {"kind": "exporter", "data_type": "logs", "name": "debug"}
2024-05-31T12:39:43.055-0400 info [email protected]/service.go:140 Starting ./elastic-agent... {"Version": "8.13.4", "NumCPU": 10}
2024-05-31T12:39:43.055-0400 info extensions/extensions.go:34 Starting extensions...
2024-05-31T12:39:43.056-0400 info adapter/receiver.go:45 Starting stanza receiver {"kind": "receiver", "name": "filelog", "data_type": "logs"}
2024-05-31T12:39:43.057-0400 info [email protected]/service.go:166 Everything is ready. Begin running and processing data.
2024-05-31T12:39:43.057-0400 warn localhostgate/featuregate.go:63 The default endpoints for all servers in components will change to use localhost instead of 0.0.0.0 in a future version. Use the feature gate to preview the new default. {"feature gate ID": "component.UseLocalHostAsDefaultHost"}
2024-05-31T12:39:43.261-0400 info fileconsumer/file.go:261 Started watching file {"kind": "receiver", "name": "filelog", "data_type": "logs", "component": "fileconsumer", "path": "/var/log/system.log"}
--

. Check the {agent} status
+
Finally, confirm that {agent} is running as expected. Open a second terminal shell and run the `status` command.
+
[source,shell]
--
sudo ./elastic-agent status
--
+
The returned status indicates that {agent} is healthy and not enrolled in {fleet} (which is expected because in this example we're using standalone {agent}).
+
[source,shell]
--
┌─ fleet
kilfoyle marked this conversation as resolved.
Show resolved Hide resolved
│ └─ status: (STOPPED) Not enrolled into Fleet
└─ elastic-agent
└─ status: (HEALTHY) Running
--

4 changes: 4 additions & 0 deletions docs/en/ingest-management/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ include::elastic-agent/ingest-pipeline-kubernetes.asciidoc[leveloffset=+3]

include::elastic-agent/configuration/env/container-envs.asciidoc[leveloffset=+3]

include::elastic-agent/otel-agent.asciidoc[leveloffset=+2]

include::elastic-agent/otel-agent-configuration.asciidoc[leveloffset=+3]

include::elastic-agent/install-agent-msi.asciidoc[leveloffset=+2]

include::elastic-agent/installation-layout.asciidoc[leveloffset=+2]
Expand Down