Skip to content

[Infrastructure UI] Add strict payload validation to metrics_explorer_views endpoint#160982

Merged
crespocarlos merged 26 commits intoelastic:mainfrom
crespocarlos:157520-metric-explorer-view-strict-input-validation
Jul 14, 2023
Merged

[Infrastructure UI] Add strict payload validation to metrics_explorer_views endpoint#160982
crespocarlos merged 26 commits intoelastic:mainfrom
crespocarlos:157520-metric-explorer-view-strict-input-validation

Conversation

@crespocarlos
Copy link
Copy Markdown
Contributor

@crespocarlos crespocarlos commented Jun 30, 2023

closes #157520

Summary

This PR adds strict payload validation to metrics_explorer_views endpoint. This PR depends on this to be merged #160852

How to test

  • Call the endpoint below trying to use invalid values. see here.
[POST|PUT] kbn:/api/infra/metrics_explorer_views
{
  "attributes": {
    "name": "Ad-hoc",
    "options": {
      "aggregation": "avg",
      "metrics": [
        {
          "aggregation": "avg",
          "field": "system.cpu.total.norm.pct",
          "color": "color0"
        },
      ],
      "source": "default",
      "groupBy": [
        "host.name"
      ]
    },
    "chartOptions": {
      "type": "line",
      "yAxisMode": "fromZero",
      "stack": false
    },
    "currentTimerange": {
      "from": "now-1h",
      "to": "now",
      "interval": ">=10s"
    }
  }
}
  • Set up a local Kibana instance
  • Navigate to Infrastructure > Metrics Explorer
  • In the UI, use the Saved View feature and try different field combinations

@ghost
Copy link
Copy Markdown

ghost commented Jun 30, 2023

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@crespocarlos crespocarlos changed the title 157520 metric explorer view strict input validation [Infrastructure UI] Add strict payload validation to metrics_explorer_views endpoint Jun 30, 2023
@crespocarlos crespocarlos force-pushed the 157520-metric-explorer-view-strict-input-validation branch from 467841c to c31ada9 Compare June 30, 2023 17:22
@crespocarlos crespocarlos force-pushed the 157520-metric-explorer-view-strict-input-validation branch from c31ada9 to 8a63158 Compare June 30, 2023 17:41
@crespocarlos crespocarlos added chore Feature:Metrics UI Metrics UI feature Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting v8.10.0 labels Jun 30, 2023
@crespocarlos crespocarlos force-pushed the 157520-metric-explorer-view-strict-input-validation branch from a5cac8e to ad47d14 Compare July 5, 2023 07:11
@crespocarlos crespocarlos force-pushed the 157520-metric-explorer-view-strict-input-validation branch from ad47d14 to 8617361 Compare July 5, 2023 07:12
@crespocarlos crespocarlos marked this pull request as ready for review July 5, 2023 11:55
@crespocarlos crespocarlos requested a review from a team July 5, 2023 11:55
@crespocarlos crespocarlos requested a review from a team as a code owner July 5, 2023 11:55
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/infra-monitoring-ui (Team:Infra Monitoring UI)

@crespocarlos
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@crespocarlos
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@crespocarlos
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@crespocarlos crespocarlos requested a review from neptunian July 12, 2023 13:00
metricsExplorerViewId: rt.string,
});

export type GetMetricsExplorerViewResposePayload = rt.TypeOf<typeof metricsExplorerViewRT>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export type GetMetricsExplorerViewResposePayload = rt.TypeOf<typeof metricsExplorerViewRT>;
export type GetMetricsExplorerViewResposePayload = rt.TypeOf<typeof metricsExplorerViewRT>;

typo missing 'n' in GetMetricsExplorerViewResponsePayload

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️

createMetricsExplorerViewRequestPayloadRT,
FindMetricsExplorerViewResponsePayload,
findMetricsExplorerViewResponsePayloadRT,
GetMetricsExplorerViewResposePayload,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
GetMetricsExplorerViewResposePayload,
GetMetricsExplorerViewResponsePayload,

@crespocarlos crespocarlos requested a review from neptunian July 12, 2023 19:01
@crespocarlos
Copy link
Copy Markdown
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Copy Markdown

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #20 / prerelease_packages should install latest stable version and ignore prerelease packages

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
infra 2.0MB 2.0MB -3.6KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
infra 103.6KB 105.0KB +1.4KB
Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 14 16 +2
securitySolution 411 415 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 15 17 +2
securitySolution 490 494 +4
total +6

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@maryam-saeidi maryam-saeidi self-requested a review July 14, 2023 10:09
Copy link
Copy Markdown
Member

@maryam-saeidi maryam-saeidi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AO code changes LGTM!

@crespocarlos crespocarlos merged commit a0a83c1 into elastic:main Jul 14, 2023
@crespocarlos crespocarlos deleted the 157520-metric-explorer-view-strict-input-validation branch July 14, 2023 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting chore Feature:Metrics UI Metrics UI feature release_note:skip Skip the PR/issue when compiling release notes Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services v8.10.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Infra Monitoring UI] update metrics-explorer-view interfaces to have strict types for validation

6 participants