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

Integrate Asset Inventory with backend #208417

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

albertoblaz
Copy link
Contributor

@albertoblaz albertoblaz commented Jan 27, 2025

Summary

Fetch and render backend data upon opening the Asset Inventory page.

Depends on

Screenshots

Screenshot Screenshot 2025-01-30 at 17 09 12

Definition of done

  • Asset Inventory page fetches data prepared by the data-view that comes pre-installed with the "Cloud Asset Inventory" integration
    • Search bar
    • Filters
    • Data Grid
    • Empty state when number of fetched rows is zero

How to test

  1. Prepare cloud user
    • Go to users page on Elastic Cloud
    • Create a new user with a custom username and password
    • Copy the same roles from the user called paulo_remote_dev
  2. Start local env running these commands
    • Run ES with node scripts/es snapshot --license trial -E path.data=../default -E reindex.remote.whitelist=cb8e85476870428d8c796950e38a2eda.us-west2.gcp.elastic-cloud.com:443 -E xpack.security.authc.api_key.enabled=true
    • Run Kibana with yarn start --no-base-path
  3. Go to Integrations page, switch on the "Display beta integrations" control, then add the Cloud Asset Inventory integration on your local environment. Postpone Elastic Agent addition.
  4. Go to Dev Tools page, click on the "config" tab and add the following environment variables:
    Use the dev tools config tab to save your as follows:
  5. Run the following script:
Script
POST _reindex?wait_for_completion=false
{
  "conflicts": "proceed", 
  "source": {
    "remote": {
      "host": "${ES_REMOTE_HOST}",
      "username": "${ES_REMOTE_USER}",
      "password": "${ES_REMOTE_PASS}"
    },
    "index": "logs-cloud_asset_inventory*",
    "query": {
      "bool": {
        "must": [
          {
            "range": {
              "@timestamp": {
                "gte": "now-1d"
              }
            }
          }
        ]
      }
    }
  },
  "dest": {
    "op_type": "create",
    "index": "logs-cloud_asset_inventory.asset_inventory-default"
  },
  "script": {
    "source": """
      ctx._source['entity.category'] = ctx._source.asset.category;
      ctx._source['entity.name'] = ctx._source.asset.name;
      ctx._source['entity.type'] = ctx._source.asset.type;
      ctx._source['entity.sub_type'] = ctx._source.asset.sub_type;
      ctx._source['entity.sub_category'] = ctx._source.asset.sub_category;
    """
  }
}

Finally, open Discover page and set the DataView filter on the top-right corner to logs-cloud_asset_inventory.asset_inventory-*, as in the screenshot below. If the grid is populated, you've got data and the whole setup worked!

Discover page ![discover-page](https://github.com/user-attachments/assets/5e719e64-0b99-4f0a-9687-1821d70fb84e)

Checklist

  • Unit or functional tests were updated or added to match the most common scenarios
  • This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The release_note:breaking label should be applied in these situations.
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines

Identify risks

No risks at all.

@albertoblaz albertoblaz added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting Team:Cloud Security Cloud Security team related labels Jan 27, 2025
@albertoblaz albertoblaz self-assigned this Jan 27, 2025
@elasticmachine
Copy link
Contributor

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!

@albertoblaz albertoblaz force-pushed the asset-inv-integrate branch 3 times, most recently from ad74938 to b23c8a5 Compare January 31, 2025 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Cloud Security Cloud Security team related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants