cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ActiveGate remote plugins: varying metrics

STiAT
Advisor

Hi!

 

I've written an ActiveGate plugin for NetScaler which uses SNMP instead of the one you provide via Web API since our network admins seem reluctant to turn on the rest api interface on our netscalers for me to have less work.

In your plugin you describe something like:

Content Switching Virtual Servers (split by virtual server)

  • Virtual service up %
  • Hits
  • Usage requests
  • Usage response

And that's exactly what I want to do in my module, have metrics "split by virtual server", "split by service". I can read via SNMP which vServers there are, and in example get metrics like if they're running or not, but I couldn't find any documentation on how to do the "split by vServer" part.

The vServers vary in name and number depending on the host, so I want to report those metrics for each vServer. There must be an option to do this, since you seem to do this pretty much with your NetScaler plugin.

How do I make groups for metrics? How do I create a group in example called like a vSerer with according metrics below them? To be true, I'm currently only interested if they're up or not, so it would be pretty fine for me too if i could dynamically add a metric which is not necessarily described in the plugin.json which is a UP/DOWN metric for each vServer.

Any hints on how I can achieve that? Currently I get a list of vServers with ther online/offline status, but if I work like that I'd have to know each vServer by name beforehand and add them to the plugin.json. Because the vServers vary from NetScaler to NetScaler, I'd have to have one plugin for each netscaler. Which isn't a really nice option to think about:

        vserverstatus = self.getVServerStatus()
        for vserver in vserverstatus:
            device.absolute(key="vServer %s" % (vserver), value=vserverstatus[vserver])

Since you / Dynatrace uses this "per xxx" things sometimes, I bet there is a way but I couldn't find it.

Best regards,

Georg

11 REPLIES 11

AntonioSousa
DynaMight Guru
DynaMight Guru

I don't have the NetScaler knowledge to help here, I do know a lot about SNMP, but that is probably not useful here.

If no one else replies, you might want to take a look at the SNMP extension referenced in the following link, that also contains other useful implementations, including some extensions that group metrics, and which implementations might be useful to you:

https://community.dynatrace.com/questions/240492/view.html

Antonio Sousa

In this case it's rather not about SNMP but about how to build a topology for like having a server with sub-services which hold metrics.

I think I found some type of answer in the k8s example you linked.

They seem to create an element on top of the current topology:

group = self.topology_builder.create_group(id, name)
topology_element = group.create_element(id, name)
topology_element.add_endpoint(external_ip, 80)

and seem to add metrics on top of that:

element.relative(key=metric['key'], value=metric['value'], dimensions=metric['dimensions'])


This could be close to what I want to do... create a group like vServers, create an element with the name (iE myvserver1, myvserver2), and append the metric below. If this actually creates the metric.

Any further ideas or suggestions on top of this?

david_lopes
Dynatrace Mentor
Dynatrace Mentor

Hello,


Yes, I suggest you use the dimensions feature to send the metrics.


Dimensions are splits of metrics. So define a dimension called "Virtual Server" in your metric definition. And call device.absolute for each Virtual Server, passing the Virtual Server name as the dimension:

device.absolute("requests", metric_value, dimensions={"Virtual Server": virtual_server_name})

I suggest you take a look at


examples\demo_activegate_plugin_multi

Folder that comes with the plugin_sdk, it has a metric called databases.table_size that implements dimensions.

I didn't find proper documentation about dimensions, I thought that was a feature to tell the range (dimension) of the value which is to be supplied.

I'll try that, thank you!

This does not seem to work for me properly, maybe I'm implementing it wrong:

Code:

vserverstatus = self.getVServerStatus()
        for vserver in vserverstatus:
            if NSEntityState(vserverstatus[vserver]) == "up":
                device.absolute("vServerStatus", 1, dimensions={"vserver_status": str(vserver)})
            else:
                device.absolute("vServerStatus", 0, dimensions={"vserver_status": str(vserver)})


plugin.json:

{
            "timeseries": {
                "key":"vServerStatus",
                "unit":"Count",
                "displayname":"vServer Status",
                "dimensions": ["vserver_status"]
            }, "entity": "CUSTOM_DEVICE"
},


Still, it just shows the following, no split to see between the different vServers:


Any ideas about that?

As a side-note, I could do with the dimensions what I wanted most likely. In the data it was split by dimensions, just the default-charts don't honor that. I had to create a group / charts that actually do that, binding them to the metrics behind:

With this chart section it worked for me:

"ui": {
        "charts":[
            {
                "group": "Network Errors",
                "series": [
                    {
                        "key": "NetworkinErrors",
                        "displayname": "inErrors",
                        "color": "#008cdb",
                        "seriestype": "line",
                        "rightaxis": false,
                        "stacked": false
                    },
                    {
                        "key": "NetworkoutErrors",
                        "displayname": "outErrors",
                        "color": "#008cdb",
                        "seriestype": "line",
                        "rightaxis": false,
                        "stacked": false
                    },
                    {
                        "key": "NetworkinDiscards",
                        "displayname": "inDiscards",
                        "color": "#008cdb",
                        "seriestype": "line",
                        "rightaxis": false,
                        "stacked": false
                    },
                    {
                        "key": "NetworkoutDiscards",
                        "displayname": "outDiscards",
                        "color": "#008cdb",
                        "seriestype": "line",
                        "rightaxis": false,
                        "stacked": false
                    }
                ]
            }
        ]
    },


Thanks for the hint David!

Hi Georg.

I am developing an ActiveGate Extension in wich I have a Metric with 2 Dimensions but I am running into an issue: none of the two values are being stored into it.

This is the Metric definition in the plugin.json File:

{

"entity": "CUSTOM_DEVICE",

"timeseries": {

"key": "trains.wait2",

"unit": "Count",

"dimensions": ["train", "locationstation"],

"displayname": "trains.wait2"a

}

}

And this is the Python Code to insert the values into it:

self.device.absolute("trains.wait2", oFieldValue['Wait1'], {"train": str(self.szTrain), "stationlocation": str(self.szLocationStation)})

According to the official Documentation on Dynatrace, the dimensions Parameter is a Dictionary of two strings {'key', 'value'}

If I define the Metric with only 1 Dimension, it works:

{

"entity": "CUSTOM_DEVICE",

"timeseries": {

"key": "trains.wait2",

"unit": "Count",

"dimensions": ["train"],

"displayname": "trains.wait2"

}

}

self.device.absolute("trains.wait2", oFieldValue['Wait1'], {"train": str(self.szTrain})

Please can you tell me what is wrong ?

Thank you very much.

Your dimension name doesn't match. In the plugin.json you have locationstation in your code you have stationlocation

Hi David.

You´re totally right, I wrote the Metric definition wrongly.

Once fixed, it is still not working for me, neither passing 1 Dimension at the at time nor passing 2 Dimensions in 2 steps in the Python Code:

{

"entity": "CUSTOM_DEVICE",

"timeseries": {

"key": "trains.wait2",

"unit": "Count",

"dimensions": ["train", "stationlocation"],

"displayname": "trains.wait2"

}

}

Mode #1 (Passing the 2 Dimensions at the same time)


self.device.absolute("trains.wait2", oFieldValue['Wait1'], {"train": szTrain, "stationlocation": szStationLocation})

Mode #2 (Passing the 2 Dimensions in 2 steps)


self.device.absolute("trains.wait2", oFieldValue['Wait1'], {"train": szTrain})

self.device.absolute("trains.wait2", oFieldValue['Wait1'], {"stationlocation": szStationLocation})


Thank you in advance.

Hi David.

Now it is working for me, I have put a "hardcode value" as the Metric value (123) and it works:

self.device.absolute("trains.wait2", 123, {"train": szTrain , "stationlocation": szStationLocation})

I can chart the Metric and see its 2 Dimensions: "train" and "stationlocation"

Thank you very much.

Hi David.

I´m very glad, my "Two-Dimension Metric" is working no problems from my ActiveGate Extension. I can chart it by selecting its Dimension(s), in this case by "Station":

Regards.

Featured Posts