Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import the references of dashboard assets using the Saved Objects API #27647

Merged
merged 3 commits into from
Aug 31, 2021

Conversation

kvch
Copy link
Contributor

@kvch kvch commented Aug 30, 2021

What does this PR do?

This PR changes the dashboard loading by first loading its references and then loading the dashboards.

Why is it important?

If the assets are not loaded in the proper order, the import can fail with unknown references.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
    - [ ] I have made corresponding change to the default configuration files
    - [ ] I have added tests that prove my fix is effective or that my feature works
    - [ ] I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Aug 30, 2021
@kvch kvch requested review from jsoriano and adriansr August 30, 2021 14:44
@kvch kvch added the Team:Elastic-Agent Label for the Agent team label Aug 30, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/agent (Team:Agent)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Aug 30, 2021
@kvch kvch added backport-v7.15.0 Automated backport with mergify backport-v7.16.0 Automated backport with mergify labels Aug 30, 2021
@@ -69,7 +69,7 @@ func KibanaDashboards(moduleDirs ...string) error {
// Convert 7.x dashboards to strings.
err = sh.Run(pythonExe,
filepath.Join(esBeatsDir, "libbeat/scripts/unpack_dashboards.py"),
Copy link
Member

Choose a reason for hiding this comment

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

Oh, a script we should migrate to go (not now 🙂).

continue
}
referencePath := filepath.Join(base, "..", ref.Type, ref.ID+".json")
err := loader.ImportDashboard(referencePath)
Copy link
Member

Choose a reason for hiding this comment

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

Adrian mentioned that Kibana "fails" with status 200 if it cannot import any dashboard because of missing references. Should we check the content of the response in ImportDashboards so we detect this kind of issues earlier?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@elasticmachine
Copy link
Collaborator

elasticmachine commented Aug 30, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2021-08-30T16:05:15.064+0000

  • Duration: 147 min 44 sec

  • Commit: 1c5cf22

Test stats 🧪

Test Results
Failed 0
Passed 53713
Skipped 5325
Total 59038

Trends 🧪

Image of Build Times

Image of Tests

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 53713
Skipped 5325
Total 59038

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

👍

if !kibanaResult.Success {
var errs multierror.Errors
for _, err := range kibanaResult.Errors {
errs = append(errs, fmt.Errorf("error: %s, asset ID=%s; asset type=%s; references=%+v", err.Error.Type, err.Id, err.Type, err.Error.References))
Copy link
Member

Choose a reason for hiding this comment

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

I guess that there can be other types of errors here, and other errors may not have anything to do with references, so err.Error.Refereces will be nil. But we can revisit this later if we find this is problematic, or we need to get more info for for other kinds of errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The whole error parsing from Kibana is very fragile, so I agree. I have removed the previous error check because it is just going to break. It would be nice if we could get HTTP errors when errors do happen: e.g. missing references.

@kvch kvch merged commit b90370d into elastic:master Aug 31, 2021
mergify bot pushed a commit that referenced this pull request Aug 31, 2021
…#27647)

## What does this PR do?

This PR changes the dashboard loading by first loading its references and then loading the dashboards.

## Why is it important?

If the assets are not loaded in the proper order, the import can fail with unknown references.

(cherry picked from commit b90370d)
kvch added a commit that referenced this pull request Aug 31, 2021
…#27647) (#27664)

## What does this PR do?

This PR changes the dashboard loading by first loading its references and then loading the dashboards.

## Why is it important?

If the assets are not loaded in the proper order, the import can fail with unknown references.

(cherry picked from commit b90370d)

Co-authored-by: Noémi Ványi <kvch@users.noreply.github.com>
kvch added a commit that referenced this pull request Aug 31, 2021
…#27647)

This PR changes the dashboard loading by first loading its references and then loading the dashboards.

If the assets are not loaded in the proper order, the import can fail with unknown references.

(cherry picked from commit b90370d)
kvch added a commit that referenced this pull request Sep 1, 2021
…#27647) (#27665)

This PR changes the dashboard loading by first loading its references and then loading the dashboards.

If the assets are not loaded in the proper order, the import can fail with unknown references.

(cherry picked from commit b90370d)

Co-authored-by: Noémi Ványi <kvch@users.noreply.github.com>
mdelapenya added a commit to mdelapenya/beats that referenced this pull request Sep 1, 2021
* master:
  Forward port 7.14.1 changelog to master  (elastic#27687)
  Addressing multiple dashboard issues: deps loading once, field conversion, etc. (elastic#27669)
  Remove adaptive queue sizes from agent's spec files (elastic#27653)
  Osquerybeat: Improve testability and unit test coverage (elastic#27591)
  Osquerybeat: lockdown flagsfile, prevent global defaults (elastic#27611)
  Import the references of dashboard assets using the Saved Objects API (elastic#27647)
  Fix bug with override path in cgroups (elastic#27620)
  Allow Kibana client to authorize with Elasticsearch API key (elastic#27540)
  Filebeat auditd: Fix Top Exec Commands dashboard visualization (elastic#27638)
  [elastic-agent] Fix docker tar.gz generation for complete image (elastic#27621)
  Follow up changes in dashboards in mage check && fix minor issue (elastic#27553)
  [Heartbeat] Fix bug where `enabled: false` is ignored. (elastic#27615)
  Support kube_state_metrics v2.0.0 (elastic#27552)
Icedroid pushed a commit to Icedroid/beats that referenced this pull request Nov 1, 2021
…elastic#27647)

## What does this PR do?

This PR changes the dashboard loading by first loading its references and then loading the dashboards.

## Why is it important?

If the assets are not loaded in the proper order, the import can fail with unknown references.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v7.15.0 Automated backport with mergify backport-v7.16.0 Automated backport with mergify Team:Elastic-Agent Label for the Agent team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants