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

Python EF2 topology setting

Yosi_Neuman
DynaMight Guru
DynaMight Guru

Hi guys,

We  have start to convert python EF1 to EF2, we managed to convert already few of them but and now we are a bit confused on how to create the topology within extension.yaml and how to set the values from __main__.py

We did not found any documentation or example for this kind of change or settings.

Wonder if we missed it or its really not there 🤔

Anyhow, can someone please help and show us the equivalence of the follows EF1 code:

 

 

        for i in range (0,int(data['metaData']['totalHits'])):
            g1 = self.topology_builder.create_group("AlteonCloud", "AlteonCloud")
            e1 = g1.create_element("Alteon Cloud - " + self.group, "Alteon Cloud - " + self.group)
            ip = self.Alteon_url.replace("https://","")
            e1.add_endpoint(ip)

        for i in range (0,10):
            try:
                ip = self.Alteon_ips.split(",")[i]
                e1.add_endpoint(ip)
            except:
                break     

        for i in range (0,int(data['metaData']['totalHits'])):
            e1.absolute(key="blockedHttpTransactions",value=data["data"][i]["row"]['blockedHttpTransactions'])
            e1.absolute(key="passiveHttpTransactions",value=data["data"][i]["row"]['passiveHttpTransactions'])
            e1.absolute(key="cleanHttpTransactions"  ,value=data["data"][i]["row"]['cleanHttpTransactions'])

 

 

In EF2 extension.yaml and __main__.py

Thanks in advance

Yos

dynatrace certificated professional - dynatrace master partner - Matrix Soft Ware Division - Israel
3 REPLIES 3

Julius_Loman
DynaMight Legend
DynaMight Legend

Topology is handled differently. You cannot create topology directly from code, you need to send logs/metrics/traces/events and create generic topology types and relations which you can package into extension 2.0. Topology in EF2 has a significant drawback compared to EF+ - you need to send data at least every 5 minutes to keep entities alive. This can result in increased costs depending on your case. 

This means you won't have any continuity in terms of topology and after rewriting your extension to EF2 your devices from EF1 will no longer exist and generic topology from EF2 will create new devices. 
Also the custom topology won't have any automatically created relations unless you specify it in the custom topology relations. In EF1 you could create custom devices with specific IP addresses and smartscape automatically created relations. For example, if you monitored an appliance and there are outgoing requests from OneAgent monitored services to that appliance a link was established and you could see a service on top of a custom device. This is no longer possible.

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

TomásSeroteRoos
Dynatrace Helper
Dynatrace Helper

As @Julius_Loman mentions below, you can no longer create custom devices directly from code. Instead you have to first declare them in your extension.yaml file and then ingest metrics/logs in accordance to the sources you specify.

extension.yaml

topology:
  types:
    - name: alteon-cloud
      displayName: Alteon Cloud
      enabled: true
      rules:
        - idPattern: alteon_cloud_{ip}
          instanceNamePattern: "Alteon Cloud {ip}"
          sources:
            - sourceType: Metrics
              condition: $prefix(alteonCloud.)
          role: default

(the settings here correspond mostly to what you see in the UI under generic topology)

With the snippet above your extension.yaml file you will be creating a generic topology rule in Dynatrace which will attempt to create Altean Cloud entities from any metric with prefix alteonCloud. . These metrics should have an ip dimension which will uniquely identify the entity, as indicated by the entity idPattern (meaning you will have a different entity per ip in your metric dimensions).

You would then ingest these metrics in your python code. For example:

__main__.py

class ExtensionImpl(Extension): ... def query(self):
... self.report_metric(key=alteonCloud.blockedHttpTransactions, value=data[stuff], dimensions={"ip": "your_ip", **other_dimensions})
    ...

 

Thank you both @Julius_Loman & @TomásSeroteRoos  for the detailed explanation and code sample 

Apricate it a lot 

Yos 

dynatrace certificated professional - dynatrace master partner - Matrix Soft Ware Division - Israel

Featured Posts