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

pgi_name in Extensions 2.0

guptasahil942
Participant

Hello Team,

I am migrating extensions to framework 2.0. It seems that pgi_name is deprecated in new framework.
 
How can I find the group_instance_id in new framework ?
 
from ruxit.api.snapshot import pgi_name
pgi = self.find_single_process_group(pgi_name('sftpserver'))
pgi_id = pgi.group_instance_id
4 REPLIES 4

TomásSeroteRoos
Dynatrace Advisor
Dynatrace Advisor

In EF2 you will need to use the get_snapshot() method to access the OneAgent snapshot file with PG and PGI information.

The Snapshot object then has a get_process_groups_by_technology method that you could use.

Try something like this (untested code):

 

from dynatrace_extension import Extension

class ExtensionImpl(Extension):

  def query(self):

    snapshot = self.get_snapshot() # returns a Snapshot object

    pg_list = snapshot.get_process_groups_by_technology("sftpserver") # returns list[Entry]

    for pg in pg_list:

       pgi_id = pg.group_instance_id

The above solution did not work. So , used Read entity API token in Extension to fetch and filter pgi id . 

could you please share the stapes and the code to read 

self.get_snapshot()

You should be able to simply call self.get_snapshot like I exemplified above to get the OneAgent snapshot file (which by default /var/log/dynatrace/oneagent/plugin/oneagent_latest_snapshot.log on Linux and %PROGRAMDATA%\dynatrace\oneagent\log\plugin\oneagent_latest_snapshot.log).

If you are running the extension locally in development mode (with dt-sdk run) you will need to specify the path yourself. The recommended approach is you copy an example snapshot file into your development directory and use that.

Featured Posts