Skip to content

Commit

Permalink
Port logs service.name docs to stateful (#4116)
Browse files Browse the repository at this point in the history
(cherry picked from commit 03c32c3)
  • Loading branch information
mdbirnstiehl authored and mergify[bot] committed Aug 6, 2024
1 parent 8545be7 commit 4119599
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/en/observability/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ include::configure-logs-sources.asciidoc[leveloffset=+3]

include::logs-monitor-datasets.asciidoc[leveloffset=+2]

include::logs-add-service-name.asciidoc[leveloffset=+2]

include::logs-index-template.asciidoc[leveloffset=+2]

include::logs-troubleshooting.asciidoc[leveloffset=+2]
Expand Down
62 changes: 62 additions & 0 deletions docs/en/observability/logs-add-service-name.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[[add-logs-service-name]]
= Add a service name to logs

Adding the `service.name` field to your logs associates them with the services that generate them.
You can use this field to view and manage logs for distributed services located on multiple hosts.
If you've enabled Elastic's new experience, adding a service name also associates your logs with a service in the {kibana-ref}/services.html[Services inventory].

To add a service name to your logs, either:

* Use the `add_fields` processor through an integration, {agent} configuration, or {filebeat} configuration.
* Map an existing field from your data stream to the `service.name` field.

[discrete]
[[use-the-add-fields-processor-to-add-a-service-name]]
== Use the add fields processor to add a service name

For log data without a service name, use the {fleet-guide}/add_fields-processor.html[add_fields processor] to add the `service.name` field.
You can add the processor in an integration's settings or in the {agent} or {filebeat} configuration.

For example, adding the `add_fields` processor to the inputs section of a standalone {agent} or {filebeat} configuration would add `your_service_name` as the `service.name` field:

[source,console]
----
processors:
- add_fields:
target: service
fields:
name: your_service_name
----

Adding the `add_fields` processor to an integration's settings would add `your_service_name` as the `service.name` field:

[role="screenshot"]
image::images/add-field-processor.png[Add the add_fields processor to an integration]

For more on defining processors, refer to {fleet-guide}/elastic-agent-processor-configuration.html[define processors].

[discrete]
[[map-an-existing-field-to-the-service-name-field]]
== Map an existing field to the service name field

For logs that with an existing field being used to represent the service name, map that field to the `service.name` field using the {ref}/field-alias.html[alias field type].
Follow these steps to update your mapping:

. From the main {kib} menu, go to **Stack Management** → **Index Management** → **Index Templates**.
. Search for the index template you want to update.
. From the **Actions** menu for that template, select **Edit**.
. Go to **Mappings**, and select **Add field**.
. Under **Field type**, select **Alias** and add `service.name` to the **Field name**.
. Under **Field path**, select the existing field you want to map to the service name.
. Select **Add field**.

For more ways to add a field to your mapping, refer to {ref}/explicit-mapping.html#add-field-mapping[add a field to an existing mapping].

[discrete]
[[additional-ways-to-process-data]]
== Additional ways to process data

The {stack} provides additional ways to process your data:

* **{ref}/ingest.html[Ingest pipelines]:** convert data to ECS, normalize field data, or enrich incoming data.
* **{logstash-ref}/introduction.html[Logstash]:** enrich your data using input, output, and filter plugins.

0 comments on commit 4119599

Please sign in to comment.