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

[Dashboards++] Usage counters enhancements #186530

Closed
3 tasks done
gsoldevila opened this issue Jun 20, 2024 · 3 comments
Closed
3 tasks done

[Dashboards++] Usage counters enhancements #186530

gsoldevila opened this issue Jun 20, 2024 · 3 comments
Assignees
Labels
Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@gsoldevila
Copy link
Contributor

gsoldevila commented Jun 20, 2024

Introduction

The Dashboards++ initiative proposes using usage-counters as a means to easily add telemetry to monitor dashboard utilization. In the same lines, this document proposes further enhancements to the usage counters logic, which will benefit not only this particular use case, but usage-counters in general.

Proposed changes

Dedicated index

The first thing we propose is to use a dedicated index to store all the usage-counters saved objects. Seeing that usage-counters are going to be used more broadly, having a dedicated index to store them will help:

  • Reducing doc count and potential impact in the other system indices.
  • Isolating docs of this type easily.
  • Reducing risks / costs for migrations.
  • Adding more capacity for SO storage (at the moment each index has 1 single shard).

The .kibana split, introduced in 8.8.0, started breaking down the .kibana index in multiple SO indices.
This creates an opportunity to introduce new indices for certain SO types. Thus, we propose creating a .kibana_usage_counters index, and storing all usage-counters objects there.

There’s a small challenge though: we cannot relocate existing documents to that index, as it would require a reindex migration, and that is currently not possible due to serverless constraints (no downtime).

Luckily, we have a couple of workarounds for that:
We can deprecate usage-counters SO type and use an alternative name, e.g. usage-counter. The drawback is that we might lose half to 1 day worth of counted events during the upgrade.
This seems like an acceptable trade off (see related thread).

Namespace type: single

At the moment, usage-counters have a namespace type agnostic. In practice, this means that we are not storing any value for the namespaces property. Whilst this might be convenient for some general use cases, Dashboards++ requires per-namespace counting, e.g. how many visualizations did dashboard X have on workspace Y on the last 30 days?

Now, this could be achieved by storing the namespace as one of the 2 different properties that shape the counters’ ids: counterType, counterName. But that means:

  • We lose part of the flexibility for counter definitions.
  • We’re not taking advantage of the namespaces property that already exists for SOs.
  • The namespace management is done by the caller.
  • We can’t benefit from the RBAC policies, which could prevent users from accessing other Spaces’ usage counters.

By changing the namespace type to single, we can leverage the namespace property and allow API users doing per-Space counting. Doing this change would usually require a reindexing migration, but switching to a dedicated index gives us an opportunity to make that change without reindexing.

Counters that are currently workspace agnostic can be stored in the default namespace. Internally, the Saved Objects Repository omits the namespace: string property of the SO when using the default namespace. For usage counters that are Space-aware, the API can provide a means to allow storing the desired namespace.

Finally, in order to keep iso-functional, for Space-aware counters the kibana_usage_collection plugin will aggregate countings for each namespace.
Thus, from the Stack Telemetry standpoint, counters will be global.

Tasks

@gsoldevila gsoldevila added the Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc label Jun 20, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

@gsoldevila gsoldevila self-assigned this Jun 27, 2024
gsoldevila added a commit that referenced this issue Jul 5, 2024
…87064)

## Summary

Part of #186530.

This PR sets the basis for allowing namespaced usage counters.
It relocates `usage-counters` SO type from `.kibana` to a dedicated
`.kibana_usage_counters`.

Furthermore, the original SO type is removed, and replaced by 2 separate
types:
* `server-counters`
* `ui-counters`

Note that these 2 steps are necessary if we want to leverage
`namespaces` property of the saved objects.
We can't currently update the `namespaceType: 'agnostic'` without
causing a migration.
Thus, these two types will be defined as `namespaceType: single`.

Up until now, UI counters were stored under a special `domainId:
uiCounter`.
This forced a workaround that consisted in storing `appName:eventName`
in the `counterName` property of the SO.
Having a dedicated SO type for them allows to store `appName` as
`domainId`, avoiding the need for a
[workaround](https://github.com/elastic/kibana/blob/main/src/plugins/usage_collection/common/ui_counters.ts).

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
gsoldevila added a commit that referenced this issue Aug 5, 2024
## Summary

Part of #186530
Follow-up of #187064 

The goal of this PR is to provide the necessary means to allow
implementing the [Counting
views](https://docs.google.com/document/d/1W77qoweixcjrq0sEKh_LjIk3j33Xyy9umod9mG9BlOM/edit)
part of the _Dashboards++_ initiative.
We do this by extending the capabilities of the _usage counters_ APIs:
* We support custom retention periods. Currently data is only kept in SO
indices for 5 days. Having 90 days worth of counting was required for
Dashboards++.
* We expose a Search API that will allow retrieving persisted counters.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
@rayafratkina
Copy link
Contributor

This work is done - closing the issue

@willem-dhaese
Copy link

@rayafratkina Is there a way to view dashboard usage with these counters in gui?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
None yet
Development

No branches or pull requests

4 participants