# ActiveGate remote plugins: varying metrics

**URL:** <https://community.dynatrace.com/t/activegate-remote-plugins-varying-metrics/19878>\
**Category:** Extensions\
**Tags:** activegate, dynatrace-managed, snmp, extensions\
**Created:** [July 22, 2020, 4:46pm UTC](https://community.dynatrace.com/t/activegate-remote-plugins-varying-metrics/19878 "2020-07-22T16:46:21Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![STiAT](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@STiAT](https://community.dynatrace.com/u/STiAT)\
**Post date:** [July 22, 2020, 4:46pm UTC](https://community.dynatrace.com/t/activegate-remote-plugins-varying-metrics/19878/1 "2020-07-22T16:46:21Z")

</div>

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:

```auto
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

---

<div class="post-metadata">

**Author:** ![AntonioSousa](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/antoniosousa/32/50_2.png) [@AntonioSousa](https://community.dynatrace.com/u/AntonioSousa)\
**Post date:** [July 22, 2020, 5:02pm UTC](https://community.dynatrace.com/t/activegate-remote-plugins-varying-metrics/19878/2 "2020-07-22T17:02:41Z")

</div>

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:

[Activegate Extensions](https://community.dynatrace.com/post/113705)

---

<div class="post-metadata">

**Author:** ![STiAT](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@STiAT](https://community.dynatrace.com/u/STiAT)\
**Post date:** [July 22, 2020, 5:48pm UTC](https://community.dynatrace.com/t/activegate-remote-plugins-varying-metrics/19878/3 "2020-07-22T17:48:45Z")

</div>

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:

```auto
group = self.topology_builder.create_group(id, name)

```

```auto
topology_element = group.create_element(id, name)
topology_element.add_endpoint(external_ip, 80)

```

and seem to add metrics on top of that:

```auto
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?

---

<div class="post-metadata">

**Author:** ![david\_lopes](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/david_lopes/32/27273_2.png) [@david\_lopes](https://community.dynatrace.com/u/david_lopes)\
**Post date:** [July 22, 2020, 7:59pm UTC](https://community.dynatrace.com/t/activegate-remote-plugins-varying-metrics/19878/4 "2020-07-22T19:59:12Z")

</div>

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:

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

```

I suggest you take a look at

```auto
examples\demo_activegate_plugin_multi

```

Folder that comes with the plugin\_sdk, it has a metric called **databases.table\_size** that implements dimensions.

---

<div class="post-metadata">

**Author:** ![STiAT](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@STiAT](https://community.dynatrace.com/u/STiAT)\
**Post date:** [July 22, 2020, 8:49pm UTC](https://community.dynatrace.com/t/activegate-remote-plugins-varying-metrics/19878/5 "2020-07-22T20:49:07Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![STiAT](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@STiAT](https://community.dynatrace.com/u/STiAT)\
**Post date:** [July 22, 2020, 10:30pm UTC](https://community.dynatrace.com/t/activegate-remote-plugins-varying-metrics/19878/6 "2020-07-22T22:30:15Z")

</div>

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

Code:

```auto
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:

```auto
{
            "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:

 ![25834-1595456694299.png](https://global.discourse-cdn.com/dynatrace/original/2X/0/0c17c8f80009c8a1fa07f2effe53adb0733060ec.png)

Any ideas about that?

---

<div class="post-metadata">

**Author:** ![STiAT](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@STiAT](https://community.dynatrace.com/u/STiAT)\
**Post date:** [July 24, 2020, 7:06am UTC](https://community.dynatrace.com/t/activegate-remote-plugins-varying-metrics/19878/7 "2020-07-24T07:06:18Z")

</div>

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:

```auto
"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!

---

<div class="post-metadata">

**Author:** ![juanjo\_garcia](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/juanjo_garcia/32/35378_2.png) [@juanjo\_garcia](https://community.dynatrace.com/u/juanjo_garcia)\
**Post date:** [August 22, 2020, 11:51am UTC](https://community.dynatrace.com/t/activegate-remote-plugins-varying-metrics/19878/8 "2020-08-22T11:51:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![david\_lopes](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/david_lopes/32/27273_2.png) [@david\_lopes](https://community.dynatrace.com/u/david_lopes)\
**Post date:** [August 22, 2020, 12:34pm UTC](https://community.dynatrace.com/t/activegate-remote-plugins-varying-metrics/19878/9 "2020-08-22T12:34:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![juanjo\_garcia](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/juanjo_garcia/32/35378_2.png) [@juanjo\_garcia](https://community.dynatrace.com/u/juanjo_garcia)\
**Post date:** [August 22, 2020, 1:35pm UTC](https://community.dynatrace.com/t/activegate-remote-plugins-varying-metrics/19878/10 "2020-08-22T13:35:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![juanjo\_garcia](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/juanjo_garcia/32/35378_2.png) [@juanjo\_garcia](https://community.dynatrace.com/u/juanjo_garcia)\
**Post date:** [August 22, 2020, 2:53pm UTC](https://community.dynatrace.com/t/activegate-remote-plugins-varying-metrics/19878/11 "2020-08-22T14:53:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![juanjo\_garcia](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/juanjo_garcia/32/35378_2.png) [@juanjo\_garcia](https://community.dynatrace.com/u/juanjo_garcia)\
**Post date:** [August 23, 2020, 11:46am UTC](https://community.dynatrace.com/t/activegate-remote-plugins-varying-metrics/19878/12 "2020-08-23T11:46:38Z")

</div>

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”:

 ![26202-img-001.jpg](https://global.discourse-cdn.com/dynatrace/original/1X/2ed2c98f25a7e6356d77ee4476a6b0d14575b548.jpeg)

Regards.
