Commit graph

32202 commits

Author SHA1 Message Date
Paul Tavares
df22162faf
[Security Solution][Endpoint] Add kill-process API support for SentinelOne agents (#186133)
## Summary

#### Security Solution changes:

- Adds new feature flag for `kill-process` operation against SentinelOne
hosts
- Adds support for `kill-process` to the existing api for `agent_type`
of `sentinel_one`



#### Stack Connectors changes:

The following changes were done to the SentinelOne connector:

- Added additional query param to the `getRemoteScripts()` sub-action
2024-07-09 14:26:44 +02:00
Dima Arnautov
7997d6fe33
[ML] Hide ML embeddables from the "Add panel" flyout when ML feature isn't available (#187639)
## Summary

Fixes #187007 

Hides ML embeddables from the "Add panel" flyout when
1. ML feature isn't available for the user role 
2. ML is hidden in a current space 


### How to test 
1. Create a custom role with disabled ML privilege and assign it to a
user

![image](07fe2865-2ebe-448f-8e31-c36581b57b28)

2. Remove ML feature visibility in a current space 

![image](dc3f19fa-cb29-424a-a04d-677518bb45fa)

### Checklist

- [x] [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
2024-07-09 22:21:20 +10:00
Julia Bardi
5df39715a5
[Fleet] enable feature flag for reusable integration policies (#187153)
## Summary

Closes https://github.com/elastic/kibana/issues/186175
2024-07-09 14:12:41 +02:00
Dmitrii Shevchenko
045aafcfea
[Security Solution] Implement isCustomized calculation (#186988)
**Resolves: https://github.com/elastic/kibana/issues/180145**
**Resolves: https://github.com/elastic/kibana/issues/184364**

> [!NOTE]  
> This PR doesn't include `isCustomized` recalculation when bulk editing
rules. This should be addressed separately as it might require first
changing the `RulesClient.bulkEdit` method signature.

## Summary

This PR implements the calculation of `ruleSource.isCustomized` inside
the `DetectionRulesClient`. The recalculation of the `isCustomized`
field is performed on every rule patch and update operation, including
rule upgrades. See the ticket for more information:
https://github.com/elastic/kibana/issues/180145 and
`detection_rules_client/mergers/rule_source/calculate_is_customized.ts`
for implementation details.

The `isCustomized` calculation is based on the `calculateRuleFieldsDiff`
method used inside the prebuilt rules domain for calculating changed
fields during rule upgrades. This ensures that the diff calculation
logic is unified and reused to avoid any discrepancies in different
paths of rule management.

The recalculation and saving of the field is done in the following
endpoints:
- **Update Rule** - `PUT /rules`
- **Patch Rule** - `PATCH /rules`
- **Bulk Update Rules** - `PUT /rules/_bulk_update`
- **Bulk Patch Rules** - `PATCH /rules/_bulk_update`
- **Import Rules** - `POST /rules/_import`
- **Perform Rule Upgrade** - `POST /prebuilt_rules/upgrade/_perform`

This PR also partially addresses refactoring mentioned here:
https://github.com/elastic/kibana/issues/184364. Namely:
- Splits the rule converters into smaller single-responsibility
functions.
  - Separate methods to convert RuleResponse to AlertingRule and back
  - Separate methods to apply rule patches, updates, or set defaults
  - Separate case converters
- Migrates methods to work with RuleResponse instead of alerting type
wherever possible.
- Adds new methods for fetching rules by id or rule id and deprecates
the `readRules`. Although new methods are not exposed yet in the public
client interface, this is something that needs to be addressed
separately.
2024-07-09 13:40:50 +02:00
Achyut Jhunjhunwala
2e8ca07ced
[Logs Explorer] Add logic to render degraded fields table in Logs Flyout (#186287)
## Summary

Closes - https://github.com/elastic/kibana/issues/172272
The PR adds the degraded Field Table in the Logs Flyout. The accordion
is kept closed by default. For demo purposes below screenshot will show
it expanded

This PR will also fix a very simply Flaky Test -
https://github.com/elastic/kibana/issues/186244

## Pending Items

- [x] Add Locator for Dataset Quality Page
- [x] Add tests


## Demo

![Jul-04-2024
15-54-22](4ff9ab9c-ef01-4dd4-83f0-8db9e0dad3f1)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-07-09 12:27:45 +02:00
Tomasz Ciecierski
d4db33595d
[EDR Workflows] Add x fields to osquery OpenApi schema (#187685) 2024-07-09 11:59:31 +02:00
Pablo Machado
0ee7a7a76d
[Security Solutions] Add a preview button to alerts inside the risk contribution panel (#187148)
## Summary

The feature is hidden behind the flag `entityAlertPreviewEnabled`

* It adds the extra column to the risk contribution panel with a button
that opens the alert preview panel



0677de6b-a6fa-461b-92b5-188d79e7274c




### Checklist


- [x] [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
- [x] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [x] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
2024-07-09 19:54:47 +10:00
Nick Partridge
234f97ab69
[Lens] Metric style options improvements (#186929)
## Summary
Adds 3 new options to the new `Metric` vis including:
- Title/subtitle alignment
- Value alignment
- Icon alignment
- Value fontSizing
2024-07-09 11:40:29 +02:00
Dario Gieselaar
4013f608c1
[AI Assistant] Add to dashboard (#179329)
Adds a new functionality in the AI assistant when in dashboards. If the
users ask for a question which will generate a query then then can use
prompts like:

- `Create a visualization from this query and add this to a dashboard`
- `Create a metric from this query and add this to a dashboard`
- ....


![meow](3092f006-13ce-4565-b9d3-c6ad407afb31)


### How it works
- It uses the existing functionality of the assistant to create an ES|QL
query (if the generated query is wrong is not part of this PR)
- The LLM returns the query to the new `add_to_dashboard` function and
with the chart type (if the user has added the preference) and the
configuration needed for the ConfigBuilder it creates a Lens embeddable
and adds it to the dashboard.

### How to test
- Go to advanced settings, find the `Observability AI Assistant scope`
setting and change to Everywhere
- Go to a dahsboard (existing or new)
- Ask a question to the AI such as `I want the 95th percentile of ...
from ... index` or `I want the median of butes from the
kibana_sample_data_logs grouped by the top 5 destinations`
- After the ES|QL query has been generated correctly ask AI to create a
chart from this query and add this to the dashboard


### important note
As this is the first real consumer of the build api for ES|QL I have
fixed and various bugs I discovered in the api.

---------

Co-authored-by: Stratoula Kalafateli <stratoula1@gmail.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-07-09 09:31:54 +02:00
Konrad Szwarc
e64102dc74
[EDR Workflows] Add artifact information (#184125)
This PR adds both user and global Artifacts to the Policy Response tree,
which can be found in the fleet's Policy Response flyout as well as in
the Endpoint Details panel. The data needed to render these fields is
already present in the policy_response API response. I don't believe we
need to provide any kind of backward compatibility since
`policy_response` API response seems to be carrying this info as far
back as `7.17.23` stack version (Cloud @ `7.17.23` with FS @ `7.17.23`
and Agent @ `7.17.23`), see screenshot below:

![Screenshot 2024-07-03 at 12 07
23](b0d6dd45-4036-4f64-a42b-07c35ca37684)


ac1c5048-6e9f-4e9c-b61d-e76a473c83ed

Updated styling


2ac95589-a228-4444-a781-b02055757c3b
2024-07-09 09:23:07 +02:00
Justin Kambic
dbb2e2d78b
[Observability Onboarding] Add missing translation on OTel quickstart title (#187781)
## Summary

Adds a missing translation call to one of the titles on the OTel
collector quickstart in onboarding.
2024-07-09 09:06:02 +02:00
Tim Sullivan
de495d7acf
[ESO Plugin] Migrate authc.getCurrentUser usage to coreStart.security (#187024)
Part of https://github.com/elastic/kibana/issues/186574

## Summary

This PR migrates the Encrypted Saved Object Plugin's route handler that
consumes `authc.getCurrentUser` to use `coreStart.security`.

Background: This PR serves as an example of a plugin migrating away from
depending on the Security plugin, which is a high priority effort for
the last release before 9.0.

### Checklist

Delete any items that are not applicable to this PR.

- [x] [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

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-07-08 20:27:24 -07:00
Ying Mao
c2be810de3
[Response Ops][Alerting] Deleting ad hoc run task if the last schedule entry ends in a timeout (#187496)
## Summary

Fixing bug where ad hoc run task was not getting deleted if running the
last schedule entry and the run times out.

## To Verify
1. Create a detection rule
2. Add a delay in the ad hoc task runner
```
--- a/x-pack/plugins/alerting/server/task_runner/ad_hoc_task_runner.ts
+++ b/x-pack/plugins/alerting/server/task_runner/ad_hoc_task_runner.ts
@@ -530,6 +530,7 @@ export class AdHocTaskRunner {
     } catch (err) {
       runMetrics = asErr(err);
     }
+    await new Promise((resolve) => setTimeout(resolve, 3100000));
     await this.processAdHocRunResults(runMetrics);
```
3. Schedule a backfill for the rule with only one schedule entry

```
POST https://localhost:5601/internal/alerting/rules/backfill/_schedule
[
  {
    "rule_id": <ruleId>,
    "start": "2024-07-03T13:05:00.000Z"
  }
]
```

4. Wait for the run to get cancelled then verify that the task was
deleted.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2024-07-08 20:07:57 -04:00
Lisa Cawley
6a2abd6809
[ResponseOps][Cases] Edits case template text (#187610) 2024-07-09 09:42:06 +10:00
Candace Park
fe131d4717
[Security Solution][AVC banner] Add AVC results banner to elastic defend home page and integrations (#186942)
## Summary

- [x] Shows a banner with the 2024 AVC results blog link in 2 places:
the Security homepage and the Elastic Defend integration page info
- [x] Banner will not show again once dismissed
- [x] Unit Tests 

TODO in another pr: have code to remove the avc banner code at the end
of the year

## Screenshots
<img width="1724" alt="image"
src="9ac2ca14-525b-44bc-b357-e87f10856f33">

<img width="1383" alt="image"
src="24ef70fe-dfa7-4fc1-bcba-8405aaf4f9ce">

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Paul Tavares <paul.tavares@elastic.co>
2024-07-09 05:50:54 +10:00
Jonathan Budzenski
d9c3300ecf skip failing test suite (#176336) 2024-07-08 14:26:59 -05:00
Kevin Lacabane
610c7bdbc8
[eem] fix metadata fields painless script (#187755)
## Summary

Closes https://github.com/elastic/kibana/issues/186873

The ingest pipeline painless scripts for metadata fields were not
looking at the right context fields. This was not a problem until now
because our the fields we collect had the same name in the entity
document (`source field == destination field`), but for collecting
_index we need a different destination to avoid breaking elasticsearch
internals
2024-07-08 20:04:57 +01:00
Steph Milovic
2b5ff77095
[Security solution] Add model parameter to token telemetry (#187783) 2024-07-08 12:53:25 -06:00
Sergi Massaneda
92099b277d
[Security GenAI] Use AI setting to set langsmith tracing to the Integration Assistant (#187466)
## Summary

Enables tracing Langchain invocations in the integrations assistant
using the Langsmith settings stored by the Security AI Settings.
The evaluation settings tab is still under an experimental flag, to see
it:

```
xpack.securitySolution.enableExperimental: ['assistantModelEvaluation']
```

### Screenshots

<img width="1317" alt="Settings"
src="6aed1ef6-3750-4259-9fe2-b8bf1aed5504">

After one execution of the integration assistant:

<img width="1240" alt="langsmith"
src="dd3dd99c-7c83-4a35-95b2-789e7a341031">

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2024-07-08 20:14:57 +02:00
Lisa Cawley
35ee0ccbb0
[OAS][Cases] Add case templates to case configuration APIs (#187613) 2024-07-09 04:10:38 +10:00
Walter Rafelsberger
94cab93977
[ML] AIOps: Refactors function argument structure for Log Rate Analysis. (#187669)
## Summary

Refactors the function argument structure of code used on Kibana server
for Log Rate Analysis from individual arguments to single objects that
contain all options. The options structure looks like this:

```
{
  // "meta" args like dependencies, general callbacks etc. on the outer most level
  esClient,
  abortSignal,
  ...
  // within "arguments" we pass in actual options that necessary for the logic of the function
  arguments: {
    start,
    end,
    query,
    fields,
    ...
  }
}
```

The main benefit is that code where these functions are used become
easier to read. Instead of the strict order of args that sometimes
included `undefined` or just a value where it's hard to guess for which
argument it's used for, this enforces to have the names of options show
up in the consuming code. Here's an example:

Before:

```
await fetchHistogramsForFields(
                client,
                requestBody.index,
                histogramQuery,
                [
                  {
                    fieldName: requestBody.timeFieldName,
                    type: KBN_FIELD_TYPES.DATE,
                    interval: overallTimeSeries.interval,
                    min: overallTimeSeries.stats[0],
                    max: overallTimeSeries.stats[1],
                  },
                ],
                -1,
                undefined,
                abortSignal,
                stateHandler.sampleProbability(),
                RANDOM_SAMPLER_SEED
              )
```

After:

```
                (await fetchHistogramsForFields({
                  esClient,
                  abortSignal,
                  arguments: {
                    indexPattern: requestBody.index,
                    query: histogramQuery,
                    fields: [
                      {
                        fieldName: requestBody.timeFieldName,
                        type: KBN_FIELD_TYPES.DATE,
                        interval: overallTimeSeries.interval,
                        min: overallTimeSeries.stats[0],
                        max: overallTimeSeries.stats[1],
                      },
                    ],
                    samplerShardSize: -1,
                    randomSamplerProbability: stateHandler.sampleProbability(),
                    randomSamplerSeed: RANDOM_SAMPLER_SEED,
                  },
                })) as [NumericChartData]
```


### Checklist

- [ ] [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
- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
2024-07-08 20:06:40 +02:00
Umberto Pepato
f99f83428c
[ResponseOps][Alerts] Implement platform alerts grouping components (#184635)
## Summary

Adds solution-agnostic components to create hierarchical alerts grouping
UIs, adapting the original implementation from Security Solution.

Closes #184398 

## To Verify

For existing usages of the `@kbn/grouping` package: verify that the
grouped UIs work correctly (Security Alerts, Cloud Security Posture).

New alerting UI components: checkout
https://github.com/elastic/kibana/pull/183114 (PoC PR), where the
updated `@kbn/grouping` package and these new components are used in
Observability's main Alerts page.

### Checklist

- [x] [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

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Gerard Soldevila <gerard.soldevila@elastic.co>
Co-authored-by: Vadim Kibana <82822460+vadimkibana@users.noreply.github.com>
Co-authored-by: Alex Szabo <alex.szabo@elastic.co>
Co-authored-by: Tre <wayne.seymour@elastic.co>
2024-07-08 19:23:49 +02:00
Joe McElroy
0be5528f21
[Search] [Playground] Gemini search playground + Robustness for Question Rewriting (#187559)
## Summary

Work largely based off the work @stephmilovic really nicely put together
in this [draft PR](https://github.com/elastic/kibana/pull/186934)
- Introduce Google Gemini Model support
- Updated bedrock to use the ActionsSimpleChatModel 
- Updated the tests
- Made the rewrite question chain more robust
  - the prompt is now uses the model specific tags
- the system instruction has been updated to be less wordy, better for
BM25 retrieval
 

4558bc5d-e0c1-4ff6-b68c-800441f7835e

### Checklist

Delete any items that are not applicable to this PR.

- [ ] 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/packages/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
- [x] [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
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] 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 renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

---------

Co-authored-by: Steph Milovic <stephanie.milovic@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2024-07-08 18:18:12 +01:00
Justin Kambic
62a2faab53
[Observability Onboarding] Fix onboarding nav (#187498)
## Summary

Addresses some issues with navigation in the Observability solution
related to onboarding.

### Overview page add data link


![Untitled](e9fe603c-510b-4bec-87ae-da56337811dd)

### Overview get started link

Doesn't render as an anchor because there's a telemetry call inside the
handler


![Untitled](d179721d-d2f7-49dc-bd2c-43ba0f14c1eb)

### Install Metricbeat link

Takes user to overview page pre-filtered for `infra`.

---------

Co-authored-by: Joe Reuter <johannes.reuter@elastic.co>
2024-07-09 02:47:19 +10:00
Nathan Reese
e3cc2e0cc0
decouple 'Add to case' action from legacy embeddable framework (#187293)
Part of https://github.com/elastic/kibana/issues/175138

PR decouples "Add to case" action from legacy embeddable framework. PR
also cleans up page load bundle size by moving `isCompatible` and
`execute` implemenations behind async imports.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2024-07-08 10:07:43 -06:00
Alexey Antonov
129ad61c76
fix: [Obs content] Decorative images should be ignored by screen readers (#187677)
Closes: https://github.com/elastic/observability-dev/issues/3654
Closes: https://github.com/elastic/observability-dev/issues/3655
Closes: https://github.com/elastic/observability-dev/issues/3656
Closes: https://github.com/elastic/observability-dev/issues/3657
Closes: https://github.com/elastic/observability-dev/issues/3664
Closes: https://github.com/elastic/observability-dev/issues/3665

## Description
Observability has a lot of service icons (Go, Node, Python, Postgresql,
et al) that are used to help identify the service visually. These are
excellent visual flourishes but do not offer additional information for
screen readers. We should update these icons' alt attribute to be
`alt=""` to notify screen readers these are decorative images and should
be ignored.

### Steps to recreate
Turn on a screen reader of your choosing and navigate through views
identified in screenshots that have these service images. Navigate node
to node (not using the `TAB` key) and listen to the image being
announced as a repeat of the text or just as "image".

### What was done?: 
1. For the mentioned cases, the attribute `role="presentation"` was
added to address the accessibility (a11y) issue.
2. Updated
[observability_solution/infra/public/pages/metrics/hosts/components/table/entry_title.tsx](https://github.com/elastic/kibana/pull/187677/files#diff-dfc0d2e9d12156217b6f7d886eb07e861152ec0ff75615520163dc33438c6ee6)
The tooltip for `CloudProviderIcon` showed `HostName` instead of
`CloudProviderName`. It should be updated to show a single tooltip with
the format `{cloudProviderName}: {hostName}`. This change will improve
accessibility (a11y) and remove any confusion.
<img width="632" alt="image"
src="55b0b39d-277d-4710-9700-fd1196b7d9df">
2024-07-08 19:03:13 +03:00
Alexey Antonov
c313edf685
fix: [Obs Applications > Service Detail][SCREEN READER]: Tooltips must be able to take keyboard focus: 0002 (#187579)
Closes: https://github.com/elastic/observability-dev/issues/3596

## Summary

This issue was partially fixed in the scope of [PR
#187063](https://github.com/elastic/kibana/pull/187063). This PR updates
only the table title part.

<img width="593" alt="image"
src="59a7cf63-43b6-4b76-b539-13b3b31cfb16">
2024-07-08 19:02:40 +03:00
Joe Reuter
bac808a690
Make it clear log stream panels shouldn't be used (#187548)
As discussed, I looked into making it clearer how to handle the log
stream embeddable panel on dashboards.

It's not possible to show an info icon or a badge without bigger
changes, but there is already a tooltip which can be used for the same
purpose:

<img width="321" alt="Screenshot 2024-07-04 at 11 30 27"
src="60de35b5-559f-4670-b2b9-e074a3cb73c8">

<img width="422" alt="Screenshot 2024-07-04 at 11 31 31"
src="3ba2f87c-dc33-4a6b-bf81-2e561e6b7cec">

I added the "deprecated" to the title instead.

There is code to show a "deprecated" badge, but it only works for
visualization types, not for actions (which is how log stream is
integrated here). Actions currently don't have a notion of deprecation.
It would be possible to add that, but it doesn't seem worth it to
slightly change how the "deprecated" text is rendered.
2024-07-08 17:11:27 +02:00
Nicolas Chaulet
6590457792
[Fleet] Fix privileges to delete request diagnostics (#187678) 2024-07-09 00:33:18 +10:00
Joe Reuter
ae802a5776
[OTel Onboarding] Adjust linux snippet and warning (#187691)
Address
https://github.com/elastic/observability-dev/issues/3217#issuecomment-2210741356

<img width="1150" alt="Screenshot 2024-07-05 at 17 30 47"
src="228b0531-ac16-46d0-bbf1-5c3bb959121a">
2024-07-09 00:31:42 +10:00
Lisa Cawley
dddcf2ef43
[HTTP/OAS] Add tags and summaries for saved object APIs (#184184)
Co-authored-by: Jean-Louis Leysens <jloleysens@gmail.com>
2024-07-08 09:54:52 -04:00
Pierre Gayvallet
b6fcfac9c1
[Kibana logging system] Add conditional evaluation based on level for logging APIs (#187225)
## Summary

*(Yeah, the title is pretty bad I apologize, I couldn't find something
sexy. OTOH, "sexy" and "logging" are usually antonyms, like "sport car"
and "fiat panda", or "server language" and "javascript")*

### 1. Provide a more developer-friendly alternative to
`Logger.isLevelEnabled`.


**With `isLevelEnabled`**
```ts
if(logger.isLevelEnabled('info')) {
  const message = someExpensiveMessageProbablyBasedOnJsonStringifyOrSomething(); 
  logger.info(message);
}
```

**With this PR:**
```ts
logger.info(() => someExpensiveMessageProbablyBasedOnJsonStringifyOrSomething());
``` 

### 2. Adapt calls to `log.debug` (arguably) costly to use this syntax

Aka any call relying on `JSON.stringify` or function calls.

I used the new syntax for those, except when the tests were too
complicated to fix or when the code did not allow it (e.g. untyped let
variables infered from return from assignations don't play well with
closures)
2024-07-08 23:53:02 +10:00
Connor Yager
6c1e955e8b
Remove unused code for redundant groupBy field in custom threshold and metric threshold rules (#184787)
## Summary

Closes #184712

Previously, when a user tries to create an alert with a `groupBy` with a
field that is already filtered down to just one match by the KQL query,
the UI would warn them that the filter query already contains an exact
match. However, this is not desirable behavior, as adding "redundant"
groupBy fields can be used to trigger alerts for data storage scenarios.
Regardless, this warning is not currently being enforced by the UI and
the warning was never enforced by the API, so this change removes the
logic.

Change that had initially implemented this logic:
https://github.com/elastic/kibana/pull/111891

This screenshot shows an example alert configuration that would
previously have gotten a warning:


![Screenshot 2024-06-04 at 4 48
37 PM](aa160f4f-b7e6-493f-a551-a6995cffedb5)


### Checklist

Delete any items that are not applicable to this PR.

- [X] 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/packages/kbn-i18n/README.md)
- [X] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [X] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [X] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: Maryam Saeidi <maryam.saeidi@elastic.co>
2024-07-08 14:51:22 +02:00
Achyut Jhunjhunwala
548becfa61
[Dataset Quality] Remove unit test from server side (#187635)
## Summary

This PR removed almost all API level Units tests from the Server folder
of our code. Server Side code should always be tested using API test,
Functional test and Integration test. Units test only when there is
complex logic which does post processing of data fetched from the DB.

Unnecessary Unit tests on Server side comes with the cost of maintenance
which is not worth. Hence removing them here.
i kept 1 Unit test file which was testing a scenario around
`uncategorizedOnly` scenario which is not exposed via API. I am not sure
why it was added, but then i didn't see any compelling reason to remove
them.
2024-07-08 22:41:47 +10:00
Ignacio Rivas
0ba6746ad6
[Index management] Link component templates (#187360) 2024-07-08 13:40:42 +02:00
Bharat Pasupula
a347d7b5f1
[Security Gen AI] [ Integration Assistant ] Modify pipeline template to handle dates as array of string in the logs (#187643)
## Summary

There could be
[scenario](https://docs.paloaltonetworks.com/iot/iot-security-api-reference/iot-security-api/get-vulnerability-instances)
where a date can come in as an array -

`"detected_date": [
        "2021-04-19T23:59:59"
        ],`

The `date` processor fails to handle an array with a string.
This PR adds a `script` processor as a pre processor to date processor
to convert the array of string into a string.

Pipeline after the changes

```json
{
      "script": {
        "tag": "script_convert_array_to_string",
        "description": "Ensures the date processor does not receive an array value.",
        "lang": "painless",
        "source": "if (ctx.palo_alto_iot.vulnerability.detected_date instanceof ArrayList){\n    ctx.palo_alto_iot.vulnerability.detected_date = ctx.palo_alto_iot.vulnerability.detected_date[0];\n}\n"
      }
    },
    {
      "date": {
        "if": "ctx.palo_alto_iot?.vulnerability?.detected_date != null",
        "tag": "date_processor_palo_alto_iot.vulnerability.detected_date",
        "field": "palo_alto_iot.vulnerability.detected_date",
        "target_field": "event.start",
        "formats": [
          "ISO8601"
        ]
      }
    }
```

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2024-07-08 09:08:14 +02:00
Marta Bondyra
e6f17e7c06
[Unified field list] debounce search (#187143)
## Summary

Updates to unified field list on typing are debounced - this way we
don't get so many updates when typing in the search input.

Flaky test runner:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/6424

## Performance comparison
Test: typing the string: activem for metricbeat data (~6000 fields)

before (costly update on every keystroke):
<img width="669" alt="Screenshot 2024-06-28 at 17 28 38"
src="7075f7bc-2d90-4177-acac-69ac101b2ef1">

after (only one costly update when user stops typing):
<img width="269" alt="Screenshot 2024-06-28 at 17 24 43"
src="8c0ce4a3-7c1a-428b-a482-f6b4d87911e0">
2024-07-06 14:47:26 +02:00
Søren Louv-Jansen
4504088b9a
[Obs AI Assistant] Add ES function API test (#187465)
Related to https://github.com/elastic/kibana/issues/180787
2024-07-06 18:12:10 +10:00
Ersin Erdal
da1c32d57c
Classify ES|QL verification_exception as user error (#187668)
Resolves: #187268

This PR classifies the verification_errors thrown by the Elasticsearch
Query (ES|QL) rules as user error.

## To verify

Create an Elasticsearch Query with ES|QL and use anon-existing field in
the query.
Let the rule run.
`/api/task_manager/metrics?reset=false` should show a user error under
`alerting:__es-query"`

```
"alerting:__es-query":{"success":0,"not_timed_out":1,"total":1,"total_errors":1,"user_errors":1,"framework_errors":0}
```

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-07-05 12:20:29 -04:00
Milton Hultgren
3ef5de826d
[EEM] Align naming of components (#187507)
This PR aligns the naming of the entity discovery framework components
to the following pattern:
`entities-{schema version}-{history|latest}-{definition ID}` (with a few
differences here and there, the index has a leading dot, some indices
have a date after them).

---------

Co-authored-by: Chris Cowan <chris@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-07-06 01:46:06 +10:00
Gloria Hornero
24d5083648
[Security Solution] Updates QG naming (#187631)
## Summary

We are updating the namings of the QG to be aligned with the
requirements given by Kibana.
2024-07-06 01:32:21 +10:00
Ash
fffc684d4e
[SecuritySolution][Endpoint] Update Responder command definition test so that it fails when new commands are added (#187491)
## Summary

Updates test so that it fails whenever we add a introduce a new
responder command.

### Checklist
- [x] [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
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
2024-07-05 16:51:39 +02:00
Joe Reuter
53722d541f
Adjust OTel onboarding manifest (#187674)
* Update onboarding manifest based on
https://github.com/elastic/opentelemetry-dev/pull/307
* Use latest snapshot
2024-07-05 16:50:38 +02:00
Konrad Szwarc
68d5370369
[EDR Workflows] Create missing OpenAPI specs for Endpoint management API (#187261)
This PR adds OpenAPI schemas for Defend Workflows API endpoints that
previously didn't have them. Here are the changes made:
1. Added a schema for `/api/endpoint/isolate`, which is deprecated and
now redirects as a `308` to the new path
(`/api/endpoint/action/isolate`). It's tagged with `x-labels` as `ess`
only.
2. Added a schema for `/api/endpoint/unisolate`, which is deprecated and
now redirects as a `308` to the new path
(`/api/endpoint/action/unisolate`). It's tagged with `x-labels` as `ess`
only.
3. Added a schema for
`/api/endpoint/protection_updates_note/{package_policy_id}`.
4. Added `x-labels` field to all existing Defend Workflows API paths for
proper tagging.

For more information on `x-labels`, please refer to
https://github.com/elastic/kibana/pull/184348
2024-07-06 00:34:12 +10:00
Chris Cowan
4802a0fe63
[EEM] Remove @timestamp from latest schema mappings (#187514)
## Summary

This PR removes `@timestamp` from the latest index template mappings.
This will help users who explore `.entities-observability.latest-v1.*`
in Discover ES|QL by using the date picker to filter the results.

### Testing

Using the following ES|QL in Discover:

```
FROM .entities-observability.latest-v1.* | LIMIT 10
```

The date picker should look like this:

<img width="932" alt="image"
src="bf75c785-44f6-41b9-b12f-661327012819">

Co-authored-by: Milton Hultgren <milton.hultgren@elastic.co>
2024-07-05 15:47:19 +02:00
Jan Monschke
2849829560
[SecuritySolution] Add OpenAPI schema for the timeline resolve enspoint (#186373)
## Summary

Adds an OpenAPI schema for the timeline resolve endpoint.

(Fixes https://github.com/elastic/kibana/issues/183810)

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2024-07-05 22:59:59 +10:00
Søren Louv-Jansen
1040bae640
[Obs AI Assistant] Make resource names static (#187489)
This changes the resource names from being stateful to being static.
This makes it easier to import them since they don't have to be passed
around, and "go-to-definition" actually takes you to the implementation
point instead of the types.
2024-07-05 13:43:57 +02:00
Ievgen Sorokopud
0a4ed61699
[Security Solution][Detections][BUG] ES|QL rule execution error when source document has a non-ECS compliant sub-field with data under event field (#187384) (#187549)
## Summary

Ticket https://github.com/elastic/kibana/issues/187384

These changes fix the error on saving the alert
> An error occurred during rule execution: message: "[1:6778] failed to
parse field [kibana.alert.original_event.action] of type [keyword] in
document with id '027b925ae2799635a0dee97a6aa9d58dc87d9771'."

which happens due to not stripping non-ECS compliant sub-fields of the
`event.action` field.

See the main ticket for steps to reproduce the issue.
2024-07-05 13:29:22 +02:00
Stratoula Kalafateli
7b635f3246
[Obs AI assistant] Replace with double quotes (#187327)
## Summary

Follow up of https://github.com/elastic/elasticsearch/pull/108395

### Checklist

- [ ] [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

---------

Co-authored-by: Søren Louv-Jansen <sorenlouv@gmail.com>
2024-07-05 12:54:45 +02:00
Dima Arnautov
3a9b01cf22
[ML] Removes info callout mentioning ML nodes for serverless environment (#187583)
## Summary

Fixes https://github.com/elastic/kibana/issues/187575

Remove an info callout mentioning the number of ML nodes for serverless
environment
2024-07-05 10:19:51 +03:00