## Summary
Closes#190218
This PR aims to fix the multiple requests produced when interacting with
the custom links flyout, using `memo` and `useMemo` from React to
prevent rerenders and redundant api calls.
https://github.com/user-attachments/assets/f8b058cd-dc02-41ef-8389-809a006b8eda
## How to test
1. Start Kibana and run any synthtrace scenario
2. Go to APM -> Settings -> Custom Links
3. Play with the inputs, the calls should be made once per field (if you
already requested service.name, it will be cached, regardless of which
input you are using)
## Summary
Similar to #217034, #217202 and #217467 this time applied to
`react-use`.
This is a slightly different approach than #217034 as we're caching here
only the most common/frequently used methods from the `react-use`
library and leaving the rest to be loaded within the specific plugin
chunks.
What this PR does it fundamentally:
* adds `7.x kb` to the shared bundle
* overall the startup bundle size shrinks about `3.5 kb`
* the async bundle size shrinks of about `350 kb` (mainly due to 3
imports which were targeting `react-use/lib`).
An alternative approach would be to just fix the async import strings in
there, but I thought to it was worth it to make the long step here.
Feedback appreciated.
## Summary
This PR fixes:
1. refreshing controls when the alert search bar is refreshed
2. the extra initial loading of the alert table in the alerts page
(related to https://github.com/elastic/kibana/issues/183412)
Closes https://github.com/elastic/kibana/issues/207736
This change expands the current e2e ensemble test for K8S OTel flow to
also check application instrumentation. The test opens the APM service
inventory, finds and click on the instrumented application and checks
that at least one transaction is visible on the service details screen.
[🔒 Corresponding PR in Ensemble
repo](https://github.com/elastic/ensemble/pull/536).
> [!NOTE]
> This change needs to be merged and deployed on edge before we can
enable the test on Ensemble side because a couple of test IDs were added
to the UI
### How to test
1. Create a local K8S cluster (e.g. using minikube)
2. Add a java application to the cluster which later be instrumented
using these commands:
```
kubectl create namespace java
kubectl apply -f - <<EOF
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: java-app
name: java-app
namespace: java
spec:
replicas: 1
selector:
matchLabels:
app: java-app
template:
metadata:
labels:
app: java-app
spec:
containers:
- name: java-app
image: docker.elastic.co/demos/apm/k8s-webhook-test
env:
- name: OTEL_INSTRUMENTATION_METHODS_INCLUDE
value: "test.Testing[methodB]"
EOF
```
4. Run kibana locally and navigate to the K8S OTel flow
5. Run the Playwright test:
```
npx playwright test -c ./x-pack/solutions/observability/plugins/observability_onboarding/e2e/playwright/playwright.config.ts --project stateful --reporter list --headed x-pack/solutions/observability/plugins/observability_onboarding/e2e/playwright/stateful/kubernetes_otel.spec.ts
```
6. Once the test pauses, go through the onboarding instructions,
including the instrumentation part (use `java-app` as application name
and `java` as the namespace in the instrumentation command)
7. Wait for the test to un-pause and continue
## Summary
Resolves#210025
Introduces starter API for bulk purging of SLI data.
**docs coming pending review**
Users can submit a list of SLO ids for which they would like to purge
rollup data, as well as a purge policy:
```
"purgePolicy": {
"purgeType": "fixed_age",
"age": "1w"
}
```
```
"purgePolicy": {
"purgeType": "fixed_time",
"age": "2025-04-01T00:00:00Z"
}
```
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
## Summary
This PR refactors the `createEvents` function to improve the readability
the execution along with optimizations. Part of the refactor is to
remove the recursiveness to reduce the chances of "blowing the stack". I
also added a back-off feature to the queue so when it's saturated the
process will wait progressively longer until things improve. I also
changed the how the continuous "wait" works. If it falls too far behind,
it will index as fast as it can to catch up and vise-versa it will wait
longer if it get's too far ahead of the current time.
To test the back-off, run the following command. If you keep increasing
the events-per-cycle, eventually it will saturate the queue and start
backing off.
```
node x-pack/scripts/data_forge.js --dataset fake_hosts --lookback now-5m --events-per-cycle 10000 --index-interval 10000
```
This also includes an optimizations for the `fake_hosts` dataset. Before
this change, `randomBetween` would create arrays with all the possible
numbers then randomly sample them 🤮 (lazy programming). The new
implementation just calculates the random value between the min and max,
mods that number by the `step` argument, then subtracts the remainder to
bring the number down to the closes step. For example if you do
`randomBetween(0, 10, 5)` you will get either `0`, `5`, or `10`.
I also refactored how the network values so the counters for
`system.network.[in|out].bytes` match the
`host.network.[ingress|egress].bytes` gauges so if you where to compare
them on a Lens visualization, the values would match (as they should).
And last but not least... I added a new option `--slash-logs` that will
index this data directly to `logs` without installing index templates,
pipelines, or components. This is useful for testing the new Streams
feature. Use [the commands from this
Gist](https://gist.github.com/simianhacker/4116a6def82f1270722fef1366e3d422)
to enable and setup streams, then test with:
```
node x-pack/scripts/data_forge.js --dataset fake_stack --lookback now-5m --events-per-cycle 10 --index-interval 10000 --slash-logs
```
Closes#214557
### Summary
Use `traceId` to generate url link to Span as fallback when
`transactionId` is missing.
### How to test
1. Run the following synthtrace scenario: `node scripts/synthtrace
span_links.ts --live --uniqueIds --clean --logLevel=debug --scenarioOpts
pipeline=apmToOtel`
2. Go to **Service** -> **Transactions** -> in **Transaction waterfall**
click **Span Links** label -> select **Outgoing links** from downdown ->
check if **Span** link works
https://github.com/user-attachments/assets/c22fdc5e-7ba9-4817-a78b-bf5fb9a53651
---------
Co-authored-by: jennypavlova <dzheni.pavlova@elastic.co>
## Summary
Partially addresses #210531.
This doesn't fully fix the ticket linked, as elements that control the
annotation look in the second half of the form still trigger re-renders.
This means the focus will still be lost when those elements are
modified.
This is going to require significant refactoring of this form, but this
patch will at least make the elements reachable via tabbing.
The custom `onBlur` removed here doesn't seem to impact the form and the
rendering issues are prominent in any case.
Co-authored-by: Dominique Clarke <dominique.clarke@elastic.co>
## Summary
Part of #213045
This PR fixes an issue when the `observability:entityCentricExperience`
flag is enabled.
By some reason, we may get null values in `sourceDataStreams` and when
we try to validate it with the zod schema, it breaks.
Closes: #215689
**Description:**
When user clicks on add panel and then selects any of the observability
embeddable panels (SLO burn rate, SLO Overview, SLO Alerts, SLO Error
budget, Monitors overview, Monitors stats), Kibana announces them as
"you are in a modal dialog. Press escape or tap click outside the
dialog....This doesn't give non-sighted user context about the add panel
action they are trying to execute.
**Changes Made:**
1. Added `aria-labelledby={flyoutTitleId}` for mentioned places
## Summary
This PR only renames the helper, no test implementations were changed.
Why now?
Migrating tests from Enzyme to RTL means that all usage of
`mountWithIntl` has to change and will likely be replaced by the helper
that wraps RTL render with I18n. [A shorter name improves devEx](url).
ATM, consumption is limited to a few tests, reducing the number of
codeowner reviews required.
### Identify risks
- [x] In progress work and open PRs might fail. Updating from main will
prompt an undefined function that will need to be renamed.
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
## Summary
Closes#218063
This PR fixes the broken storybook stories we have for Infra.
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
**!!MAJORITY OF THE CHANGED FILES ARE MOVED OR COPIED!!**
### Vision
According to the product vision we will build a new simple UI/UX in the
future https://github.com/elastic/security-team/issues/11790
This PR is a first iteration on enabling Content Connectors Management
UI in Serverless Kibana Stack Management.
Elastic Managed content connectors will be available only for Security
and Observability projects.
### Current PR scope
1. Used initial search_connectors plugin and renamed it to
content_connectors + moved from `x-pack/solutions/search` to
`x-pack/platform/plugins/shared`
2. Copy relevant connectors UI and routes from enterprise_search plugin.
3. Introduce the new Stack Management card/navigation option under the
Data section.
4. Enabled this plugin only in Serverless for Security and Observability
projects.
5. For making PR smaller Pipelines tab was not moved. And according to
Search team vision this functionality should be dropped anyway soon.
6. Extended fleet package logic to include elastic_connectors for
security and o11y serverless projects
7. Added back `search:agentless-connectors-manager` task
In Stack Management navigation:
<img width="2062" alt="Screenshot 2025-04-15 at 3 51 43 PM"
src="https://github.com/user-attachments/assets/5c93ba01-9a6a-4eac-a21d-1370f03b8f35"
/>
Stack Management cards:
<img width="2081" alt="Screenshot 2025-04-10 at 8 41 43 PM"
src="https://github.com/user-attachments/assets/3def1c12-561b-4a84-8241-4dd61cd9313d"
/>
Create Elastic Managed Connector UI (on Agentless):
<img width="1822" alt="Screenshot 2025-04-15 at 3 55 29 PM"
src="https://github.com/user-attachments/assets/6e9fea48-85e7-43df-919d-0e5492d0e704"
/>
Create Self Managed Connector UI:
<img width="2064" alt="Screenshot 2025-04-15 at 3 55 49 PM"
src="https://github.com/user-attachments/assets/d5051898-c8fa-4e41-b9ea-b41d4ed4a0d5"
/>
### Next steps
- [ ] Remove duplicated code between content_connectors,
enterprise_search and serverless_search
- [ ] Extract [common server
libs](https://github.com/elastic/kibana/tree/main/x-pack/solutions/search/plugins/enterprise_search/server/lib)
to the shared package `kbn-search-connectors`
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Steph Milovic <stephanie.milovic@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Artem Shelkovnikov <artem.shelkovnikov@elastic.co>
Co-authored-by: Artem Shelkovnikov <lavatroublebubble@gmail.com>
Co-authored-by: Kyle Pollich <kyle.pollich@elastic.co>
For the embeddable waterfall to be successful, we want to remove
unnecessary information and be able to select which records should be
displayed.
We need to remove:
- Accordions
- Services Legend
We want to display (or hide anything that isn't):
- root,
- direct parent,
- current span or transaction (highlighted)
- up to 2 children.
- Errors will be represented with an icon in the embeddable form of the
waterfall and the badge in the regular form
https://github.com/user-attachments/assets/bf8d34d7-173c-4a1a-8ccf-2f98f43fc625
## Using the embeddable:
1: Loads standard trace waterfall (like the one on APM UI)
```
<ReactEmbeddableRenderer
type="APM_TRACE_WATERFALL_EMBEDDABLE"
getParentApi={() => ({
getSerializedStateForChild: () => ({
rawState: {
serviceName: 'foo',
traceId: 'e7b9d541fae0e25106291f7ac0947acd',
entryTransactionId: '2d94d9d4fda31c18',
rangeFrom: '2025-03-26T00:00:00.513Z',
rangeTo: '2025-03-26T20:52:42.513Z',
displayLimit: 5, //optional param when omitted it renders the entire waterfall
},
}),
})}
hidePanelChrome={true}
/>
```
2: Loads focused trace waterfall (some trace events are hidden and a
summary is available)
```
<ReactEmbeddableRenderer
type="APM_TRACE_WATERFALL_EMBEDDABLE"
getParentApi={() => ({
getSerializedStateForChild: () => ({
rawState: {
traceId: 'e7b9d541fae0e25106291f7ac0947acd',
rangeFrom: '2025-03-26T00:00:00.513Z',
rangeTo: '2025-03-26T20:52:42.513Z',
docId: SPAN_OR_TRANSACTION_ID
},
}),
})}
hidePanelChrome={true}
/>
```
## Summary
After #217202 and #217034 this the another attempt with `lodash` and
`lodash/fp`.
In short:
`lodash` and `lodash/fp` have a special webpack treatment as they are
imported within the shared bundle.
Now webpack is not smart enough to understand that `import camelCase
from 'lodash/camelCase';` is still pointing to `lodash` and it thinks
that `lodash/camelCase` is a different package, de-optimizing the
bundling caching system.
So I’ve tweaked the import to make it point to the shared bundle and
save few kbs here and there
## Summary
Pre-requisite for https://github.com/elastic/kibana/pull/216088, as the
`AI Assistant Management` configuration settings should be available for
Search too.
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
## Summary
Just had some fun and made fp-ts available in the shared bundle, with
support for partial imports.
Changes in this PR:
* aligned `fp-ts` direct imports to the format: `fp-ts/<module>`
* Mapped the direct imports into the shared bundle re-using the same
`fp-ts` module under the hood
Closes#213943
## Summary
This PR ensures the service name is always encoded in the APM UIs. It's
a follow-up of https://github.com/elastic/kibana/pull/215031 and aims to
find a better solution to the problem:
- Add the encoding directly to `formatRequest` as suggested there
- I saw that there are many places where we use legacy Url builders, so
I will try to replace them where possible and use
apm router link method where the path is encoded
([ref](7158e0201b/src/platform/packages/shared/kbn-typed-react-router-config/src/create_router.ts (L184-L185)))
- The PR includes the changes to address the issue above:
- Replaced and removed `LegacyAPMLink`
- Refactored `useAPMHref` to support encoding (and extracted and test
the encoding logic)
- Example usage:
- Before:
```js
useAPMHref({
path: `/services/${serviceName}/.....`,
persistedFilters,
});
```
- After:
```js
useAPMHref({
path: '/services/{serviceName}/.......}',
pathParams: { serviceName },
persistedFilters,
});
```
- Used the APM router link method as much as possible
## Testing
- Run `node scripts/synthtrace trace_with_service_names_with_slashes.ts
--clean --live --uniqueIds --live`
- Go to service inventory and click the links:
https://github.com/user-attachments/assets/fcd4fbfc-4125-4cc8-9b00-53c5f375423f
Closes https://github.com/elastic/kibana/issues/208025
This change deleted the "Stream log files" onboarding flow which is now
replaced by the Auto Detect flow.
| Before | After |
| --- | --- |
| 
| 
|
Changes made:
* Deleted UI components responsible for rendering the Custom Logs flow
* Deleted the definition for a custom card in the onboarding search
results
* Deleted API endpoints and supporting files used only by the Custom
Logs flow
* `/internal/observability_onboarding/logs/setup/environment` endpoint
was still used by the OTel Host flow, so it was moved to a dedicated
OTel route and pathname changed to
`/internal/observability_onboarding/otel_host/setup`
* Functionality of the `/internal/observability_onboarding/otel/api_key`
endpoint was merged into the above mentioned OTel route, so UI has to
make a single API request to get all the necessary information from the
server
* Deleted Scout UI tests for the Custom Logs flow
* Deleted API integration tests for the deleted endpoints
* API tests that we previously testing
`/internal/observability_onboarding/logs/flow` were converted to test
`/internal/observability_onboarding/flow'` used by the Auto Detect flow
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
## Summary
This PR fixes the issue with the error summary missing items using edot.
It includes e2e tests with synthtrace for both edot and otel services.
TODO
- [x] Test with serverless (waiting for the PR to be deployed)
Tested on serverless works as expected:
<img width="2560" alt="image"
src="https://github.com/user-attachments/assets/8dd7962e-7d66-482d-97fb-0b08882bd04f"
/>
Allow group by for ip fields !!
---------
Co-authored-by: Faisal Kanout <faisal.kanout@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
## Summary
Fix https://github.com/elastic/kibana/issues/217923
Investigations in https://github.com/elastic/kibana/issues/217368 showed
that there was basically no performance impact to passing the AST across
a thread boundary. But we also didn't detect a pressing reason to remove
the worker.
Since then, however, we noticed another cost associated with the worker:
it's a hefty Javascript file, even in production builds. In addition, we
are doing parsing on the main thread _and_ the worker, so the
`kbn-esql-ast` package is actually being loaded and parsed twice by the
browser, once for the main thread and once for the worker.
This PR removes our worker. Our parsing associated with validation and
autocomplete will still be done asynchronously, but on the main thread.
I do not see any regression in perceived performance.
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
This PR closes#215668.
The global parameters are synched in the endpoints where they are
created, edited or deleted.
---------
Co-authored-by: Shahzad <shahzad31comp@gmail.com>
fixes [#189213](https://github.com/elastic/kibana/issues/189213)
## Summary
Checks whether the user has permission to ML before triggering requests
to fetch ML data
### How to test
- Create a user whose role doesn't have permission to ML, but has
permission to O11y apps
- Run `node scripts/synthtrace infra_hosts_with_apm_hosts --live
--clean`
- Navigate to Inventory Infrastructure / Hosts View
---------
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
## Summary
This PR fixes the existing usage of the chart themes by using the
provided `useElasticChartsTheme` hook that is color mode aware and theme
adaptive (borealis/amsterdam)
Some charts where using just the Light theme version or the legacy (aka
amsterdam theme), and I've applied the hook to pick up the correct
theme.
TO REVIEWERS: Please pull down the PR and check if the actual changed
charts looks correct with the new theme configuration.
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Anton Dosov <anton.dosov@elastic.co>
## Summary
Partially address https://github.com/elastic/kibana/issues/216459
This PR adds `@emotion/babel-preset-css-prop` to jest config to improve
jest and emotion integration. There are some tradeoffs: this is a better
setup for emotion + testing library, but there are some seemingly
regressions for enzyme. We think these are right tradeoffs to make,
since we optimize for emotion+testing library.
### Main upsides are 😄
#### 🟢 Fixes snapshots with css prop
`You have tried to stringify object returned from \`css\` function. It
isn't supposed to be used directly (e.g. as value of the \`className\`
prop), but rather handed to emotion so it can handle it (e.g. as value
of \`css\` prop).` is replaced with proper emotion css classname.

#### 🟢 We will be able to use jest style matchers for emotion
`toHaveStyleRule`
https://emotion.sh/docs/@emotion/jest#tohavestylerule
_they can be used locally now, but we plan to follow up with global
extend_
### Considerations 🫤
#### 🟡 jsx doesn't work inside jest.mock function
Example:
```
jest.mock('./components/alert_header_title', () => ({
> 27 | AlertHeaderTitle: jest.fn().mockReturnValue(<div></div>),
| ^
28 | }));
```
Fails with an error. `can't read jsx of undefined`.
This is because babel compiles this into:
```
import { jsx as ___EmotionJSX } from '@emotion/react'
jest.mock('./components/alert_header_title', () => ({
> 27 | AlertHeaderTitle: jest.fn().mockReturnValue(___EmotionJSX.jsx(….)),
| ^
28 | }));
```
And, apparently, due to how jest imports work, __EmotionJSX is not yet
in the scope.
The applied workaround is to rewrite to:
```
jest.mock('./components/alert_header_title', () => ({
AlertHeaderTitle: jest.fn(() => <div></div>),
}));
```
#### 🟡 euiTheme needs to be available when euiTheme is accessed inside
`css` function
Example:
```
DashboardGrid removes panel when removed from container
TypeError: Cannot read properties of undefined (reading 'size')
42 | margin: '-2px',
43 | position: 'absolute',
> 44 | width: euiTheme.size.l,
```
The fix was to wrap failing tests with `<EuiProvider/>`
### Drawbacks 😢
Mostly related to Enzyme
#### 🔴 Enzyme shallow snapshot no longer include `css` prop
Since `css` prop is compiled away there are bunch of snapshots that
looks like a regression:
Example:

This is unfortunate. We've tried `@emotion/jest/enzyme-serializer` but
it didn't work (likely because enzyme ecosystem no longer supported?)
If it is important that the snapshot captures css, we recommend to use
mount or rtl
#### 🔴 Asserting against `css` prop with shallow render also doesn't
work
Possible solution is to use
```
import { matchers } from '@emotion/jest';
expect.extend(matchers);
```
(We plan to add these matches globally in a follow up)
and
```
expect(button).toHaveStyleRule('background-color', '#FFFFFF');
```
#### 🔴 Some shallow Enzyme tests `find()` breaks because of code
transformations of emotion
Example:
```
const component = shallow(
<MetricVisValue />
)
component.find('button') // fails because instead of <button/> there is <EmotionInternalCss/> element now
```
Solutions:
- Use full mount or react testing library
- Or target by data-test-subj
---------
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Karen Grigoryan <karen.grigoryan@elastic.co>
## Summary
Changes the DashboardStart server api to provide a getContentClient
function.
In https://github.com/elastic/kibana/pull/214788, we set the
`contentClient` returned from the content management register method
after start lifecycle of all plugins. This means the `contentClient`
returned from the `DashboardStart` contract was undefined. This PR
changes the start contract to provide a getContentClient function
instead.
Only one consumer was using the contentClient from DashboardStart and
this PR also updates that consumer.