After adding support for decorators an `args` property has added to
`HelperOptions` (which is shared with decorators). To not leak this into
regular helpers and to align with the upstream handlebars, this PR
removes the `args` property from regular helpers so that it's only
visible to decorators.
After moving away from composite projects in the IDE we now have an
issue where projects like security solutions are getting `@types/jest`
and `@types/mocha` loaded up, even though the "types" compiler option in
security solutions focuses on jest. To fix this I've removed the
`@types/mocha` package, implemented/copied a portion of the mocha types
into a new `@kbn/ambient-ftr-types` package which can be used in ftr
packages to define the describe/it/etc. globals.
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
## Describe the feature:
Closes https://github.com/elastic/kibana/issues/144775
This PR allows users to create more than one filter at a time. It
enhances the query builder by enabling users to create multiple filters
simultaneously. It adds the capability to nest queries and use the
logical OR operator in filter pills.
<img width="981" alt="image"
src="https://user-images.githubusercontent.com/4016496/207942022-3256590d-00f6-45c8-b566-c184d5d18953.png">
## Tasks:
- [x] Add the ability to add/edit multiple filters in one form:
- [x] Replace the current implementation of adding and editing a filter
with a filtersBuilder - `Vis-Editor`;
- [x] Add combined filter support to Data plugin (mapAndFlattenFilters)
- `App-Services`;
- [x] Add the ability to update data in the Data plugin when updating
values in the filters builder - `App-Services`;
- [x] Add hide `Edit as Query DSL` in popover case the filter inside
FiltersBuilder is combinedFilter - `App-Services`;
- [x] Update filter badge to display nested filters:
- [x] Replace the current badge filter implementation with a new one -
`Vis-Editor`;
- [x] Clean up `FilterLabel` component after replace `FIlterBadge`
component - `Vis-Editor`;
- [x] When editing filters, those filters that belong to the same filter
group should be edited - `Vis-Editor`;
- [x] Update jest and functional tests with new functionality -
`Vis-Editor`;
- [x] Fix drag and drop behavior - `Vis-Editor`;
Co-authored-by: Lukas Olson <lukas@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Alexey Antonov <alexwizp@gmail.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
Co-authored-by: Yaroslav Kuznietsov <kuznetsov.yaroslav.yk@gmail.com>
Co-authored-by: Andrea Del Rio <andrea.delrio@elastic.co>
Reverts elastic/kibana#147526
Reverting due to errors when using `FakeRequest`:
```
TypeError: Cannot read properties of undefined (reading 'remoteAddress')
at KibanaSocket.get remoteAddress [as remoteAddress] (/Users/shahzad-16/elastic/kibana/node_modules/@kbn/core-http-router-server-internal/target_node/src/socket.js:25:24)
at Object.log (/Users/shahzad-16/elastic/kibana/x-pack/plugins/security/server/audit/audit_service.ts:95:32)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Terminating process...
server crashed with status code 1
```
Resolves#127481
## Release notes
Include IP address in audit log
## Testing
1. Update `kibana.dev.yaml`:
```yaml
xpack.security.audit.enabled: true
xpack.security.audit.appender:
type: console
layout:
type: json
```
2. Observe audit logs in console when interacting with Kibana:
```json
{
"@timestamp": "2022-12-13T15:50:42.236+00:00",
"message": "User is requesting [/dev/internal/security/me] endpoint",
"client": {
"ip": "127.0.0.1"
},
"http": {
"request": {
"headers": {
"x-forwarded-for": "1.1.1.1, 127.0.0.1"
}
}
}
}
```
Note: You will see the `x-forwarded-for` field populated when running
Kibana in development mode (`yarn start`) since Kibana runs behind a
development proxy.
Co-authored-by: gchaps <33642766+gchaps@users.noreply.github.com>
## Summary
closes#146517
This PR expands the current `includeTimeseries` parameter behaviour, by
not using the `date_histogram` in the `composite` aggregation when it is
set to `false`.
This way, not only the API won't return a `timeseries` object, but the
query will calculate the aggregations on ES side as opposed to when
`includeTimeseries` is true, that does an extra `avg` and `max`
calculation on TS side using the histogram buckets.
The main motivation behind this change is to run the snapshot query
without the need of returning buckets, to avoid the max bucket error.
### How to test
- Enable the system module on metricbeat
- Start a local Kibana
- Start metricbeat
- Explore `Infrastructure > Metrics`, `Infrastructure > Inventory` and
`Infrastructure > Hosts` and play with the filters
#### cURL
##### Run a query with Composite aggregation
###### With timeseries
```bash
curl -XPOST -f 'http://0.0.0.0:5601/ftw/api/metrics/snapshot' \
-H 'kbn-xsrf:localhost' \
-H 'Content-Type: application/json' \
--data-raw '{"filterQuery":"{\"bool\":{\"must\":[],\"filter\":[],\"should\":[],\"must_not\":[]}}","metrics":[{"type":"memory"}],"groupBy":[],"nodeType":"host","sourceId":"default","accountId":"","region":"","timerange":{"from":1670859470896,"to":1670861030896,"interval":"1m","ignoreLookback":true},"includeTimeseries":true}' \
-u elastic:changeme
```
###### Without timeseries
```bash
curl -XPOST -f 'http://0.0.0.0:5601/ftw/api/metrics/snapshot' \
-H 'kbn-xsrf:localhost' \
-H 'Content-Type: application/json' \
--data-raw '{"filterQuery":"{\"bool\":{\"must\":[],\"filter\":[],\"should\":[],\"must_not\":[]}}","metrics":[{"type":"memory"}],"groupBy":[],"nodeType":"host","sourceId":"default","accountId":"","region":"","timerange":{"from":1670859470896,"to":1670861030896,"interval":"1m","ignoreLookback":true},"includeTimeseries":false}' \
-u elastic:changeme
```
##### Run a query with just Date Histogram
###### With timeseries
```bash
curl -XPOST -f 'http://0.0.0.0:5601/ftw/api/metrics/snapshot' \
-H 'kbn-xsrf:localhost' \
-H 'Content-Type: application/json' \
--data-raw '{"filterQuery":"{\"bool\":{\"must\":[],\"filter\":[],\"should\":[],\"must_not\":[]}}","metrics":[{"type":"memory"}],"groupBy":null,"nodeType":"host","sourceId":"default","accountId":"","region":"","timerange":{"from":1670859470896,"to":1670861030896,"interval":"1m","ignoreLookback":true},"includeTimeseries":true}' \
-u elastic:changeme
```
##### Without timeseries
```bash
curl -XPOST -f 'http://0.0.0.0:5601/ftw/api/metrics/snapshot' \
-H 'kbn-xsrf:localhost' \
-H 'Content-Type: application/json' \
--data-raw '{"filterQuery":"{\"bool\":{\"must\":[],\"filter\":[],\"should\":[],\"must_not\":[]}}","metrics":[{"type":"memory"}],"groupBy":null,"nodeType":"host","sourceId":"default","accountId":"","region":"","timerange":{"from":1670859470896,"to":1670861030896,"interval":"1m","ignoreLookback":true},"includeTimeseries":false}' \
-u elastic:changeme
```
### For maintainers
The `logRate` metric type <b>doesn't</b> work without being in a date
histogram, because it uses [cumulative
sum](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-cumulative-sum-aggregation.html).
Therefore `includeTimeseries` false in a `composite` aggregation will
return a 400 error. I haven't found anywhere that would make a request
like below.
#### 400 error
```bash
curl -XPOST -f 'http://0.0.0.0:5601/ftw/api/metrics/snapshot' \
-H 'kbn-xsrf:localhost' \
-H 'Content-Type: application/json' \
--data-raw '{"filterQuery":"{\"bool\":{\"must\":[],\"filter\":[],\"should\":[],\"must_not\":[]}}","metrics":[{"type":"logRate"}],"groupBy":[],"nodeType":"host","sourceId":"default","accountId":"","region":"","timerange":{"from":1670859470896,"to":1670861030896,"interval":"1m","ignoreLookback":true},"includeTimeseries":false}' \
-u elastic:changeme
```
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
## Summary
### Background
This is the last PR relating to:
https://github.com/elastic/kibana/issues/144909
The support for global settings has already been added on both the
server side and the client side. Since we went with the "two saved
objects" approach, we added a new `UiSettingsGlobalClient` on both the
[server](https://github.com/elastic/kibana/blob/main/packages/core/ui-settings/core-ui-settings-server-internal/src/clients/ui_settings_global_client.ts)
and the
[browser](https://github.com/elastic/kibana/blob/main/packages/core/ui-settings/core-ui-settings-browser-internal/src/ui_settings_global_client.ts)
to be used for setting / retrieval of globally-available settings.
### What now?
We will need to replace the signature of `uiSettings` on `CoreStart` and
`CoreSetup` as we need a way to expose a global client from there.
We had considered a few approaches:
1. Just add a new `global client` -> the easiest, but clutters the
interface
2. Change `uiSettings` to look something like:
```
uiSettings: {
client: IUiSettingsClient;
globalClient: IUiSettingsClient;
}
```
This is the cleanest, but would require changes to (almost) all plugins
3. @clintandrewhall 's idea, and something that @pgayvallet and myself
agreed on was that we would deprecate the existing `uiSettings` and
introduce a new `settings` property that would have two properties:
`client` & `globalClient`. This way we can let the teams know they
should switch to using the new service in a minimally destructive way.
The downside is that the signature differs slightly from the
server-side.
4. Open to suggestions on this.
### This PR
1. Adds a new `SettingsService` that exposes client/global client for
retrieving namespace-scoped / global settings
2. Deprecates `UISettingsService`
3. Add `globalUiSettings` to `injectedMetadata`
4. Changes `render` signature of `rendering_service`
### 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
- [ ] [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
- [ ] 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)
### Risk Matrix
Delete this section if it is not applicable to this PR.
Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.
When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:
| Risk | Probability | Severity | Mitigation/Notes |
|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces—unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes—Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |
### 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: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Replacing the landing page with new images, addresses [issue
#147384](https://github.com/elastic/kibana/issues/147384)
<img width="1710" alt="image"
src="https://user-images.githubusercontent.com/11224465/207354781-70600f14-1187-4d10-ab65-3fd7e380fe4a.png">
@yuliacech @alisonelizabeth : a couple of notes:
- I was given both SVG and PNGs, in this task I just replaced the old
PNGS with the new ones, do you think I should use SVGs instead - or does
not really matter?
- The branding team made a unique image for the "Observe my Kubernetes
infrastructure" card - I uploaded the image (`kubernetes.png` and
`kubernetes-dark.png`), but did not replace it. I tried too initially,
but kept getting errors when adding it to the`UseCase` map, so left it
for now as the page now does not show a unique image. That being said I
am more than happy to replace it - I just might need some direction 😜,
or I can create a future task for that. Whatever you think is best.
## Summary
Fixes https://github.com/elastic/kibana/issues/144452
This PR updates the guide IDs used in guided onboarding from generic
values (`observability` and `security`) to more specific values
(`kubernetes` and `siem`) which will allow us to add more guides for
observability and security in the future.
### 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
## Summary
Fixes#146164
Documentation for Connectors didn't make it into the PR that added the
new page. This fixes the broken link.
### Checklist
- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
Co-authored-by: Lisa Cawley <lcawley@elastic.co>
While working on another project I found a circular dependency between
the `@kbn/shared-ux-page-solution-nav` and
`@kbn/shared-ux-page-kibana-template-types` packages. My upcoming PR
will prevent this from happening in the future, but for now this is just
a small change to fix the issue.
Extended APM synthtrace to support mobile use cases and added a mobile
scenario that generates trace data.
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Kate Patticha <aikaterini.patticha@elastic.co>
Part of: #144296
## Summary
First step of `[ESQL] Improve the typing experience` (#144296). This PR
is the skeleton for later parts, but already supports basic parsing
scenarios.
## What was done:
- [x] Added new `ESQL` language in `@kbn/monaco` package. Parsing was
done using the `antl` syntax;
- [x] `kbnUiSharedDeps`-srcJs bundle has been optimised, all workers
have been moved into separate chunks. This gave almost minus` 2 MB` 🕺
- [x] existing `esql` lang was renamed to `sql`. In order not to confuse
anyone in the future
- [x] some code from `painless` folder was moved to `common` and reused
in ESQL (probably needs some refactoring in future)
## Next steps:
- [ ] improving `ANLT` syntax to cover all cases
- [ ] implementing `Autocomplete` feature
## How to use new `ESQL Lang`:
To use new language 2 properties should be set for `CodeEditor`
component
```ts
import { ESQL_LANG_ID, ESQL_THEME_ID } from '@kbn/monaco';
import { CodeEditor } from '@kbn/kibana-react-plugin/public';
<CodeEditor
...
languageId={ESQL_LANG_ID}
options={{
...
theme: ESQL_THEME_ID,
}}
/>
```
Currently syntax highlighting looks like:
<img width="450" alt="image"
src="https://user-images.githubusercontent.com/20072247/205685072-0658fad1-d034-4d36-a44d-6a49e7365ab3.png">
<img width="450" alt="image"
src="https://user-images.githubusercontent.com/20072247/205685220-c67db50c-6f3b-49b5-9576-d1ee68428184.png">
Will be updated in Step 2
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Marco Liberati <dej611@users.noreply.github.com>
## Summary
Replace @elastic/kibana-app-services ->
@elastic/kibana-global-experience for `kbn-monaco` package
While working on #146379 I just saw that the plugin has the wrong
code-owner. Let's fix it
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Removes all the noise from poorly written React tests and includes a
warning to explain the situation to folks
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Fixes https://github.com/elastic/kibana/issues/144051
Rather than just parsing process.argv with the default config of
getopts, which treats flags like `-u` into a "value collecting" flag,
this updates the way we call getopts so that all known jest CLI flags
are properly handled. This is accomplished by parsing the output of
`yarn jest --help` and then using that information to power `node
scripts/jest`.
To update the known CLI flags we just need to run `yarn jest --help |
node scripts/read_jest_help.mjs` (for some reason I don't understand,
Jest does not produce it's entire `--help` output when called from node,
only when called from a terminal).
## Summary
- Continuing from [PR](https://github.com/elastic/kibana/pull/146121) to
apply the same changes to the `Add to Shared Lists`.
- Fix showing the number of Linked rules correctly => in `route.ts` use
the `list.namespaceType` instead of namespaceTypes array
- Apply docs comment on the text
- Use the HeaderMenu item from the `kbn` package for the `Number of
Linked rules` menu
- Allow displaying the HeaderMenu without iconType
- Update snapshots and add tests in HeaderMenu
@maximpn brought up the issues caused by the types required by the
rison-node package, which attempted to communicate that "encoded values
must be primitive values, or recursive arrays/object of primitive
values". This isn't actually expressible in TypeScript, which lead to
many instances of `rison.encode(value as unknown as RisonValue)` which
is useless. Additionally, the rison-node library actually supports any
value and will either produce valid rison or `undefined` for that value.
To address this I'm adding a wrapper function which accepts `any` and
returns a `string`. If rison-node is totally unable to produce any rison
for the value (because the value is `undefined` or some other type like
Symbol or BigInt) the `encode()` function will throw. If you're
accepting arbitrary input you can use the `encodeUnknown()` function,
which will return a string or undefined, if the value you provided has
zero rison representation.
Like JSON.stringify() any non-circular primitive, object, or array can
be encoded with either function. If the values within those objects are
not encodable (functions, RegExps, etc) then they will be skipped. Any
object/array with the `toJSON()` method will be converted to JSON first,
and if the prototype of the object has the `encode_rison()` method it
will be used to convert he value into rison.
The changes in this PR are mostly updating usage of rison-node to use
`@kbn/rison` (which is also enforced by eslint). There are also several
changes which remove unnecessary casting.