Seeing some non-integer values for custom metrics that should return integers.

HenryTHenryT Posts: 6 New member
Playing with the new restAPI and I am looking at results for the "Number of unused indexes" 

and seeing data like this, the query should (and I suspect is) return integer values.  Why am I getting this?

     {
          "dateTime": "2024-05-21T17:26:51.8380771Z",
          "value": 0.00718123376274544
        },
        {
          "dateTime": "2024-05-21T17:36:51.8238908Z",
          "value": 0.0010450247083899555
        },
        {


Tagged:

Answers

  • Alex BAlex B Posts: 1,158 Diamond 4
    Hi @HenryT,

    To confirm, is it this custom metric https://sqlmonitormetrics.red-gate.com/number-of-unused-indexes/?

    Have you accidentally changed it to record the rate of change (is this box checked)?

    If you go to the Analysis page and select that custom metric do you see integers or decimals?

    Also, what specific API request did you use (just to check it's looking at the metric you believe it is)?

    Kind regards,
    Alex




    Product Support Engineer | Redgate Software

    Have you visited our Help Center?
  • HenryTHenryT Posts: 6 New member
    I do not have rate of change checked.

    The configuration of the metric, it is out of the box.  

     
    Here is the obfuscated call.


    http://xxx-xxxxx:8080/api/v1/metrics?metricTypeId=[Cluster].[SqlServer].[Database].[CustomMetric].%5xxxx-xxxx.xx.xxx.com:2]
  • Alex BAlex B Posts: 1,158 Diamond 4
    Hi @HenryT,

    Chatting to the team, specific support for Custom metrics wasn't included in the release.  What is the bit obfuscated at the end of the call - an entity name or the base monitor name or something else?  

    Do you have more than one custom metric added?

    Kind regards,
    Alex
    Product Support Engineer | Redgate Software

    Have you visited our Help Center?
  • HenryTHenryT Posts: 6 New member
    Yes
  • HenryTHenryT Posts: 6 New member
    For what it is worth, the custom metrics do show up when you call type types method.
  • Alex BAlex B Posts: 1,158 Diamond 4
    Hi @HenryT,

    I've mentioned that they exist to the developers.  Looking at the information for what is returned for me, it looks like the last part is the Base Monitor name and then the custom metric ID from settings.customMetrics separated by a colon:

        {
          "id": "[Cluster].[SqlServer].[Database].[CustomMetric].[localhost:20]",
          "name": "Number of unused indexes",
          "category": "localhost Custom metrics"
        }



    And if I then look to get that information from the API it shows the correct info (19):


    which is the same as what I see on the Analysis page for the metric:




    With that all said, are you looking at the correct custom metric endpoint (you showed custom metric ID=2 in the URL you linked before)?  Does the data on the Analysis graph correlate wtih what the metric is returning?

    Kind regards,
    Alex
    Product Support Engineer | Redgate Software

    Have you visited our Help Center?
  • HenryTHenryT Posts: 6 New member
    Some more detail, and this may be in part a user error by me, but it doesn't seem very clear.,

    The metric looks fine in analysis.

    I have three monitors in three locations, but this custom alert is only defined in one location—it is not the primary location. 

    I do a call to  http://MyWebInstance:8080/api/v1/metrics/types and I see the following containing 'Number of unused indexes'.

    I have three monitors, but only one has this metric.

     {
          "id": "[Cluster].[SqlServer].[Database].[CustomMetric].[MyNonPrimaryMonitorInstance:2]",
          "name": "Number of unused indexes",
          "category": "MyNonPrimaryMonitorInstance Custom metrics"
        },


        {
          "id": "[AzureSqlServer].[Database].[CustomMetric].[MyNonPrimaryMonitorInstance:2]",
          "name": "Number of unused indexes",
          "category": "MyNonPrimaryMonitorInstance Azure custom metrics"
        },

        {
          "id": "[AmazonRdsSqlServer].[Database].[CustomMetric].[MyNonPrimaryMonitorInstance:2]",
          "name": "Number of unused indexes",
          "category": "MyNonPrimaryMonitorInstance Amazon RDS SQL Server custom metrics"
        },

        {
          "id": "[AzureManagedInstance].[Database].[CustomMetric].[MyNonPrimaryMonitorInstance:2]",
          "name": "Number of unused indexes",
          "category": "MyNonPrimaryMonitorInstance Azure SQL Managed Instance custom metrics"
        },


        {
          "id": "[SqlServerInstance].[Database].[CustomMetric].[MyNonPrimaryMonitorInstance:2]",
          "name": "Number of unused indexes",
          "category": "MyNonPrimaryMonitorInstance SQL Server on Linux metrics"
        },



    This is the only relevant one I am assuming since the referenced instance is not RDS, Linux, or Azure


     {
          "id": "[Cluster].[SqlServer].[Database].[CustomMetric].[MyNonPrimaryMonitorInstance:2]",
          "name": "Number of unused indexes",
          "category": "MyNonPrimaryMonitorInstance Custom metrics"
        },



    When I do the call (I am specifying a metricTypeId only. )



    I get data back only for my primary monitoring instance (which does not have this metric defined), so I suspect it is not using the server name specified in the MetricTypeID value.  These may 

    I suspect I have reached the level of opening a support call.
  • Alex BAlex B Posts: 1,158 Diamond 4
    Hi All,

    Just to update here as well, as mentioned before specific support for Custom metrics wasn't included in the release.  It does seem to work if you only have one Base Monitor, but if you try to access Custom Metric data for a second Base Monitor, it will return the data from the custom metric with that Id on the Primary BM.

    The team have made an item to investigate this when they revisit the Rest API to see if it will fit into that work, but there are no specific plans at this point to implement it at this time should it not fit into that work.

    Kind regards,
    Alex
    Product Support Engineer | Redgate Software

    Have you visited our Help Center?
Sign In or Register to comment.