GithubHelp home page GithubHelp logo

kibana-access's Introduction

Overview

Looking into ability to show activity in terms of who is accessing dashboard and when. This is the end result of going through the steps below.

image

Environment

Elastic Cloud version 8.2.0

Steps

Enable Logging and Monitoring

Followed the Enable logging and monitoring documentation to let Elasticsearch Service (ESS) take care of configuring the monitoring agents to ship to a deployment.

image

Enable Audit Logging

Even though logs are now flowing, you still have to turn on audit logging because it is disabled by default.

This can be done by updating your Kibana settings.

image image

Review Audit Data

One way to look at these logs is through Discover so create a Data View for "elastic-cloud-logs-*" as mentioned in the Enable logging and monitoring documentation. Key fields to look at to filter the noise:

  • kibana.saved_object.type: dashboard
  • event.action: saved_object_resolve (this was important because before it was listing dashboards I hadn't actually opened)

image

Great, we can see who is accessing which dashboard and when. To complete the picture, would be nice to know which dashboard and which user instead of just their IDs.

Enriching with Dashboard title

Create a Dashboard Lookup Index

Found the dashboard titles tucked away in the hidden ".kibana" index. As I didn't want to mess around with the index itself, I reindexed it and stashed the dashboard ID into the source of the destination index.

POST _reindex
{
  "source": {
    "index": ".kibana",
    "query": {
      "match": {
        "type": "dashboard"
      }
    }
  },
  "dest": {
    "index": "dashboard-lookup"
  },
  "script": {
    "source": "ctx._source.dashboard_id = ctx._id"
  }
}

Setting Up an Ingest Pipeline

Getting the IDs to Match Up

There was a difference in the identifiers between the ".kibana" index and the audit logs ("cloud-elastic-log-*).

  • audit log shows --> "kibana.saved_object.id" : "77949db0-e1a3-11ec-80b0-21a99589f84a"
  • kibana index shows --> "_id" : dashboard: 77949db0-e1a3-11ec-80b0-21a99589f84a

To deal with that, added a Script processor to prepend "dashboard" to the ID. Whenever new logs stream in, the ID needed for lookup goes into the dashboard_id field.

String prefix = 'dashboard:';
ctx['dashboard_id'] = prefix + ctx.kibana.saved_object.id

Add an Enrichment Policy

Building on that, this enrichment poicy does a lookup on the dashboard_id and then enriches the data with the dashboard title (e.g. NSF Proposals) that we're looking for.

PUT /_enrich/policy/dashboard-enrich
{
  "match": {
    "indices": "dashboard-lookup",
    "match_field": "dashboard_id",
    "enrich_fields": ["dashboard.title"]
  }
}

Adding that Enrich processor the the ingest pipeline looks like this: image

Execute the Enrichment Policy

Don't forget, you have to execute the enrichment policy for it to take effect.

PUT /_enrich/policy/dashboard-enrich/_execute

Updating the Index Template

We want this ingest pipeline to get invoked for any new documents indexed. Add it to the settings on the index template.

image

Getting Data to Show

You may need to rollover the datastream to start getting the new fields and ingest pipeline humming.

POST elastic-cloud-logs-8/_rollover

Also you could do an update_by_query to update existing data.

POST /elastic-cloud-logs-8/_update_by_query?pipeline=dashboard-enrich
{
  "query": {
    "match": {
      "kibana.saved_object.type": "dashboard"
    }
  }
}

Still need to look into resolving user names but not too shabby... image

Limitations

Because the dashboard lookups are reindexed from the .kibana index at a point in time, any new dashboards wouldn't show unless you reindex again.

kibana-access's People

Contributors

izmaxxsun avatar

Stargazers

Jake Smith avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.