[OpAMP] parse comma separated tags list from non-identifying attributes#6769
[OpAMP] parse comma separated tags list from non-identifying attributes#6769juliaElastic wants to merge 8 commits intoelastic:mainfrom
Conversation
|
This pull request does not have a backport label. Could you fix it @juliaElastic? 🙏
|
| }, | ||
| { | ||
| name: "multiple tags", | ||
| tagsValue: "dev,west,us-west-1a", |
There was a problem hiding this comment.
using a comma separated list, when tested with an array in the otel config yaml, I was getting an error in the otel collector
tags: ["prod", "west", "us-west-1a"]
'extensions' error reading configuration for "opamp": decoding failed due to the following error(s):
'agent_description.non_identifying_attributes[tags]' expected type 'string', got unconvertible type '[]interface {}'
'service.telemetry.resource[tags]' expected type 'string', got unconvertible type '[]interface {}'
## Summary Relates elastic/ingest-dev#7062 Added new mappings in elastic/elasticsearch#145824 to kibana so the UI search works on them. To verify: Start ES from source with so the new mappings apply (switch to the branch of the ES PR): ``` yarn es source --license trial -E xpack.security.authc.api_key.enabled=true -E xpack.security.authc.token.enabled=true --source-path=/Users/juliabardi/elasticsearch -E path.data=/tmp/es-data -E xpack.ml.enabled=false -E http.host=0.0.0.0 ``` Add a collector (follow steps in elastic/fleet-server#6769) and test that the UI search works on the new fields: <img width="952" height="505" alt="image" src="https://github.com/user-attachments/assets/d776f8cd-3367-4f35-a3fa-deee5b211292" /> <img width="949" height="498" alt="image" src="https://github.com/user-attachments/assets/7045e502-0484-4cc6-937b-c878bbbead29" /> <img width="888" height="492" alt="image" src="https://github.com/user-attachments/assets/9971b2b6-acdb-474e-a3c2-a68e54779cd6" /> <img width="840" height="515" alt="image" src="https://github.com/user-attachments/assets/dd8da6c6-e546-4eef-ad43-b85cd6dae7c6" /> ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ...
|
This pull request is now in conflicts. Could you fix it @juliaElastic? 🙏 |
|
@ycombinator Could you approve again? Had to resolve conflicts. |
michel-laterman
left a comment
There was a problem hiding this comment.
I just have nitpicks
| kOpAMPMod = "opAMP" | ||
| serverCapabilities = uint64(protobufs.ServerCapabilities_ServerCapabilities_AcceptsStatus | | ||
| protobufs.ServerCapabilities_ServerCapabilities_AcceptsEffectiveConfig) | ||
| kNIATagsKey = "tags" |
There was a problem hiding this comment.
| kNIATagsKey = "tags" | |
| tagsKey = "tags" |
| meta := localMetadata{} | ||
| meta.Elastic.Agent.ID = agentID | ||
| agentType := "" | ||
| var configTags []string |
There was a problem hiding this comment.
(nitpick) Please rename to just tags
| NonIdentifyingAttributes: nonIdentifyingAttributes, | ||
| Type: "OPAMP", | ||
| Tags: []string{agentType}, | ||
| Tags: dedupeTags(agentType, configTags), |
There was a problem hiding this comment.
Why not send refactor dedupTags to be dedupeSlice and call it with dedupeSlice(append(agentType, configTags...))?
What is the problem this PR solves?
Save tags list in the top level tags field in Agent, taking from the comma separated list from non-identifying attributes
How does this PR solve the problem?
Non-identifying attributes are already added to Agent, tags need special handling because they are mapped to the top level tags field, and the comma separated string has to be parsed.
How to test this PR locally
Follow instructions in https://github.com/elastic/fleet-server/blob/main/docs/opamp.md
Download and extract otel collector, e.g.:
Create otel config to include the new metadata fields, e.g.
otel-opamp.yaml:Create API keys and start otel collector:
Check the Agent JSON in Fleet, check that tags are showing up as an array, and
non_identifying_attributesshow the new metadata fields.Check the telemetry data in Discover, and find the matching fields in
resource.attributes:Tested ESQL queries on the new fields in telemetry:
Open question:
tagsfield in collector telemetry data is not parsed to a list of strings, I'm not sure how can we fix that. The collector config doesn't accept a list, only string."tags": "dev,west,us-west-1a"Design Checklist
Checklist
./changelog/fragmentsusing the changelog toolRelated issues