oracle / oci-grafana-metrics

Grafana datasource plugin for OCI metrics
https://grafana.com/grafana/plugins/oci-metrics-datasource
Universal Permissive License v1.0
79 stars 40 forks source link

Feature request: Query database systems #273

Open Maros112358 opened 6 months ago

Maros112358 commented 6 months ago

Hello, we are using the OCI Grafana Plugin to visualize metrics for databases and pluggable databases in Grafana. We would like to template our dashboards with variables for databases and database systems so that we can then filter using those variables as dimensions. However, I do not see how to query database systems and databases when creating template variables in Templating Docs.

When creating dashboard query variable using OCI Grafana Plugin, I would expect the Query for database systems variable db_system to be something like:

database_systems($region,$tenancy)

For database variable database:

databases($region,$tenancy)

Then I could reference these variable in the in the raw query like:

CpuUtilization[1m]{resourceType="PDB", instanceName="$database", hostName="$database_system"}.mean()

As a workaround, I was thinking about using resourceId somehow to be more reusable, but I don't see how to query it using Templating Docs. Referencing database systems and databases directly seems more elegant.

mamorett commented 6 months ago

Hi. I think instanceName and hostName are dimensions of the database metrics, and not namespaces. You propose a template variable setting which can be done for a namespace (like oci_compute, oci_lbaas, etc) but cannot be done for a dimension. You may want to try to set a dimension template variable where you can choose a specific instanceName for your database metric.

Maros112358 commented 6 months ago

Hello, thank you for quick response. Yes, instanceName and hostName are dimensions of the database metrics. I need to filter according to these dimensions, where the value is a given by a query variable from the plugin. The value of the query variable depends on currently selected compartment.

If I understood your answer correctly, this is not possible right now. Correct?

mamorett commented 6 months ago

Hi. It should be possible, but you need to use a template var for the dimension accordingly. Please refer to the Dimension Template variable in the Using document: https://github.com/oracle/oci-grafana-metrics/blob/master/docs/using.md

Maros112358 commented 6 months ago

Hello @mamorett, thank you for your advice. I tried template variable for dimension and it is what I needed. However, I have one question. If I choose multi-value selection option for my dimension variable and select at least 2 options, the grafana dashboard breaks. I inspected the query and it looks like this:

CpuUtilization[1m]{{deploymentType=\"vm\",resourceName_dbnode=\"my_node\"}}.avg()"

For comparison, this is query only with only one value selected:

CpuUtilization[1m]{resourceName_dbnode=\"my_node\"}.avg()

This is the query when I use two separate dimension variables in a dashboard:

CpuUtilization[1m]{deploymentType=\"vm\",resourceName_dbnode=\"my_node\"}.avg()

Is this a bug or do I need to create new dimension variable for each dimension I want to filter?