Forum Stats

  • 3,854,725 Users
  • 2,264,414 Discussions
  • 7,905,772 Comments

Discussions

Tell us about your experience with the "Oracle Enterprise Manager App for Grafana ”

11213141618

Answers

  • raphi
    raphi Member Posts: 26 Bronze Badge

    Hi,

    has someone a list of the keywords we can use in the query to fetch data from the EM datasource into a variable, like type, targettype, emsite and so on?

    I can get all targets with this query:

    oem_gf_target_name{ "type":"target" ,"targettype":"$oem_gf_target_type" , "emsite" : "$oem_gf_emsite" }
    

    This lets me select the target I am interested in.

    Now I want another variable (hierarchically below oem_gf_target_name) that fetches only the target which matches oem_gf_target_name so I can extract a specific part of the target name with a regex, like this:

    cluster_name{ "targetname" : "$oem_gf_target_name", "type":"target" ,"targettype":"$oem_gf_target_type" , "emsite" : "$oem_gf_emsite"}
    

    And then this regex to fetch the last part of the target name:

    /.*-(.*-.*-.*)/
    

    But no matter what I try, "target", "target_name", "name" it wil always return a list of all targets in OEM, completely ignoring the setting of $oem_gf_target_name.

    Hope someone can help, I need this to work to be able to load panels from other datasources based on the target's name, which has the clustername included.

  • ganessub-Oracle
    ganessub-Oracle Member Posts: 38 Employee
    oem_gf_target_name{ "type":"target" ,"targettype":"$oem_gf_target_type" , "emsite" : "$oem_gf_emsite" }
    

    In the above JSON, the "type" part should have the keyword "target" only, you cant change that. Above JSON will fetch the target names based on the currently selected value of $oem_gf_target_type. If you are interested in fetching cluster names then in the target type drop-down did you select rac_database as target type...or if you are interested in defining a new template variable that will hold the list of cluster names then you can directly hard code the targetype as shown in the JSON below:

    cluster_name{ "type":"target" ,"targettype":"rac_database" , "emsite" : "$oem_gf_emsite" }
    

    Look at type part, it is still maintained as "target" and in the targettype hardcoded value is used. Apart from targettype, you can also hardcode emsite too.

  • raphi
    raphi Member Posts: 26 Bronze Badge

    Thanks for your reply. I didn't mention that we have targettype specified as "oracle_database", which is what I need. Our naming scheme for databases has the (grid) cluster name included and I want to extract that based on the database that was selected in the drop down.

    What I am looking for is a list of possible keys that we can use when querying EM, from the templates I only know about "type", "targettype" and "emsite" - is that all or are there more keys we could use for target selection?

    Actually, I wouldn't even need to query EM again. First the user selects a database in the $oem_gf_target_name variable, then the cluster_name variable should be set to this:

    cluster_name = $oem_gf_target_name
    regex: /.*-(.*-.*-.*)/
    

    But this seems not to be possible.

  • ganessub-Oracle
    ganessub-Oracle Member Posts: 38 Employee

    Can you define a new Query type template variable say cluster_name with this JSON:


     { "type":"target" ,"targettype":"$oem_gf_target_type" , "emsite" : "$oem_gf_emsite" }
    

    along with your regex expression, what does the Preview value show?

  • ganessub-Oracle
    ganessub-Oracle Member Posts: 38 Employee

    Also please verify whether your regular expression is correct and it is following the expected format. You can see some examples of regex here: https://grafana.com/docs/grafana/latest/variables/filter-variables-with-regex/

  • S_Lour
    S_Lour Member Posts: 10 Red Ribbon

    case 1: oem_gf_target_name{ "type":"target" ,"targettype":"$oem_gf_target_type" , "emsite" : "$oem_gf_emsite" } 

    case 2: cluster_name{ "type":"target" ,"targettype":"rac_database" , "emsite" : "$oem_gf_emsite" } 


    Only difference is this:


     A. You are replacing variable name oem_gf_target_name to cluster_name

     B. you are hard coding variable oem_gf_target_type to rac_database in Case 2


    Use regexp:


    To get only specific database db1 : /db1/

    To get only multiple databases: /db1|db2|db3/ 

    To exclude Databases: /^(?!.*DB1|DB2).*$/

    ganessub-Oracle
  • raphi
    raphi Member Posts: 26 Bronze Badge
    edited Jun 7, 2022 6:14AM

    Our DB Names in OEM are of this pattern:

    databasename-prefix-clustername-number

    Users of our grafana Dashboard only choose the DB Name they are interested in, for example: mydatabase-blue-mycluster-1

    The dropdown for this is the result of the ordinary OEM query with targettype oracle_database and whatever the user selects is saved in $oem_gf_target, which is then used to display many DB related metrics - but the DB alone is not the complete picture, to investigate potential performance issues you need check the node usage too.

    Our OS guys have node metrics saved in a different datasource than OEM which I could query if I only had the clustername, hence the regex:

    cluster_name = $oem_gf_target_name
    regex: /.*-(.*-.*-.*)/
    

    Which in this example should result in:

    cluster_name = blue-mycluster-1
    

    With this I could query an OS datasource to display in a panel say the total network or I/O usage of the nodes of the cluster blue-mycluster-1. There's little sense to investigate high single-block-read-latency of a database when the overall bandwith of the node is saturated by something else than a particular DB.

  • ganessub-Oracle
    ganessub-Oracle Member Posts: 38 Employee

    can you show us the screenshots of your cluster_name template variable configuration without a regex and with regex. We want to see the JSON and preview value part of the screen when there is no regex and when there is regex. So please capture 2 screenshots and attach.

  • raphi
    raphi Member Posts: 26 Bronze Badge
    edited Jun 7, 2022 9:47AM

    I don't have a valid definition yet of cluster_name, this does not work (because it's not a query):

    cluster_name = $oem_gf_target_name
    

    Which is why my original idea was to ask OEM to give me only a specific target based on it's name and then use the regex to cut out the clustername part. But adding "targetname" to the query does not do anything, it still shows all targets of the set type.

    Here's the config and the result - I masked the original cluster names for security reasons but you see that it is giving out multiple values like "blue-mycluster-1", "green-notmycluster-2" and so on. $oem_gf_target_name was set to "mydatabase-blue-mycluster-1".


    Is there a way at all to query a specific target name into a variable?

  • ganessub-Oracle
    ganessub-Oracle Member Posts: 38 Employee

    I need the screenshot which gets shown when u click the cluster_name variable which shows the configuration details of that variable.