[APM] Remove usage of internal client when fetching agent config etags metrics#173001
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
c59fc7b to
6499c97
Compare
|
Pinging @elastic/apm-ui (Team:APM) |
|
Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services) |
6499c97 to
36f98aa
Compare
36f98aa to
bb39c37
Compare
💛 Build succeeded, but was flaky
Failed CI Steps
Test Failures
Metrics [docs]
History
To update your PR or re-run it, just comment with: |
cauemarcondes
left a comment
There was a problem hiding this comment.
LGTM... just added small suggestions.
| }; | ||
| } | ||
|
|
||
| async function getIsAppliedByAgent({ |
There was a problem hiding this comment.
You could probably create a simple unit test to cover this function.
There was a problem hiding this comment.
This is already covered by the api test. A unit test would mock out the call to getAgentConfigEtagMetrics so it would only cover the check on agentConfiguration.applied_by_agent and appliedEtags.includes(agentConfiguration.etag. I don't think it's worth it.
If it was functionality with value in itself, then maybe, but in this case it's just an implementation detail. It might as well be inlined in findExactConfiguration instead of a separate function.
| params | ||
| ), | ||
| getConfigsAppliedToAgentsThroughFleet(internalESClient, apmIndices), | ||
| apmEventClient ? getAgentConfigEtagMetrics(apmEventClient) : undefined, |
There was a problem hiding this comment.
Can't you call getIsAppliedByAgent so the logic is in one place?
There was a problem hiding this comment.
No, getIsAppliedByAgent is for a single agent configuration. In this case we need to fetch every agent configuration, and map them with all available etags so we want to fetch those two in parallel.
…s metrics (elastic#173001) Closes: elastic#170031 Replaces: elastic/elasticsearch#101467 **Problem** We need to know if an agent config has been applied at the edge (by APM agents). This is determined by comparing the etag (hash) of the config, with the etag applied at the edges. Previously the agent config itself contained this information (`config.applied_by_agent`) but when running with fleet this will instead be captured in `agent_config` metric documents. Currently the internal kibana user retrieves the `agent_config` metric documents from the APM metric index (`metrics-apm-*` by default). This index is configurable by the end-user so can be changed to something the internal user doesn't have access to. This is a problem. **Solution** This PR replaces the calls made by the internal client with calls made by the authenticated end user (via `APMEventClient`). This approach works for requests made from the browser/UI but doesn't work for background tasks made by fleet. To work around this we only conditionally query the metric index if the `APMEventClient` is available. If `APMEventClient` is not available `applied_by_agent` will be `undefined` (cherry picked from commit 58c7958)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…s metrics (elastic#173001) Closes: elastic#170031 Replaces: elastic/elasticsearch#101467 **Problem** We need to know if an agent config has been applied at the edge (by APM agents). This is determined by comparing the etag (hash) of the config, with the etag applied at the edges. Previously the agent config itself contained this information (`config.applied_by_agent`) but when running with fleet this will instead be captured in `agent_config` metric documents. Currently the internal kibana user retrieves the `agent_config` metric documents from the APM metric index (`metrics-apm-*` by default). This index is configurable by the end-user so can be changed to something the internal user doesn't have access to. This is a problem. **Solution** This PR replaces the calls made by the internal client with calls made by the authenticated end user (via `APMEventClient`). This approach works for requests made from the browser/UI but doesn't work for background tasks made by fleet. To work around this we only conditionally query the metric index if the `APMEventClient` is available. If `APMEventClient` is not available `applied_by_agent` will be `undefined` (cherry picked from commit 58c7958)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…s metrics (elastic#173001) Closes: elastic#170031 Replaces: elastic/elasticsearch#101467 **Problem** We need to know if an agent config has been applied at the edge (by APM agents). This is determined by comparing the etag (hash) of the config, with the etag applied at the edges. Previously the agent config itself contained this information (`config.applied_by_agent`) but when running with fleet this will instead be captured in `agent_config` metric documents. Currently the internal kibana user retrieves the `agent_config` metric documents from the APM metric index (`metrics-apm-*` by default). This index is configurable by the end-user so can be changed to something the internal user doesn't have access to. This is a problem. **Solution** This PR replaces the calls made by the internal client with calls made by the authenticated end user (via `APMEventClient`). This approach works for requests made from the browser/UI but doesn't work for background tasks made by fleet. To work around this we only conditionally query the metric index if the `APMEventClient` is available. If `APMEventClient` is not available `applied_by_agent` will be `undefined` (cherry picked from commit 58c7958)
|
Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync. |
1 similar comment
|
Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync. |
|
Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync. |
|
Backported to 8.12 in #173120 |
…s metrics (elastic#173001) Closes: elastic#170031 Replaces: elastic/elasticsearch#101467 **Problem** We need to know if an agent config has been applied at the edge (by APM agents). This is determined by comparing the etag (hash) of the config, with the etag applied at the edges. Previously the agent config itself contained this information (`config.applied_by_agent`) but when running with fleet this will instead be captured in `agent_config` metric documents. Currently the internal kibana user retrieves the `agent_config` metric documents from the APM metric index (`metrics-apm-*` by default). This index is configurable by the end-user so can be changed to something the internal user doesn't have access to. This is a problem. **Solution** This PR replaces the calls made by the internal client with calls made by the authenticated end user (via `APMEventClient`). This approach works for requests made from the browser/UI but doesn't work for background tasks made by fleet. To work around this we only conditionally query the metric index if the `APMEventClient` is available. If `APMEventClient` is not available `applied_by_agent` will be `undefined` (cherry picked from commit 58c7958)
Closes: #170031
Replaces: elastic/elasticsearch#101467
Problem
We need to know if an agent config has been applied at the edge (by APM agents). This is determined by comparing the etag (hash) of the config, with the etag applied at the edges.
Previously the agent config itself contained this information (
config.applied_by_agent) but when running with fleet this will instead be captured inagent_configmetric documents.Currently the internal kibana user retrieves the
agent_configmetric documents from the APM metric index (metrics-apm-*by default). This index is configurable by the end-user so can be changed to something the internal user doesn't have access to. This is a problem.Solution
This PR replaces the calls made by the internal client with calls made by the authenticated end user (via
APMEventClient). This approach works for requests made from the browser/UI but doesn't work for background tasks made by fleet. To work around this we only conditionally query the metric index if theAPMEventClientis available.If
APMEventClientis not availableapplied_by_agentwill beundefined