Skip to content

Conversation

BraydenNeale
Copy link

Snapshot entries can sometimes include other properties such as mssql_instance_name which can be useful. In this example the instance name is used to determine the performance counter prefix.

Needed to replace the old EF1 logic of:

self.entity = kwargs["associated_entity"]
instance_name = self.entity.properties['mssql_instance_name']

This adds those properties to a dictionary called: extra_properties
Accessible via:

  snapshot = self.get_snapshot()
  for mssql_entry in snapshot.get_process_groups_by_technology("MSSQL"):
      mssql_instance_name = mssql_entry.properties.extra_properties.get("mssql_instance_name")

Example snapshot with SQLEXPRESS

{
    "host_id": "0XC5B095DDA1FA0E61",
    "entries": [
        {
            "group_id": "0X8D6D1890DCD1FAA2",
            "node_id": "0X0000000000000000",
            "group_instance_id": "0X783C15D8FC8D78CD",
            "process_type": "6",
            "group_name": "MSSQL16.SQLEXPRESS",
            "processes": [
                {
                    "pid": "19492",
                    "process_name": "sqlservr.exe",
                    "properties": [
                        {
                            "WorkDir": "C:\\WINDOWS\\system32\\"
                        },
                        {
                            "CmdLine": "-sSQLEXPRESS"
                        },
                        {
                            "ExePath": "C:\\Program Files\\Microsoft SQL Server\\MSSQL16.SQLEXPRESS\\MSSQL\\Binn\\sqlservr.exe"
                        },
                        {
                            "ParentPid": "1680"
                        }
                    ]
                },
                {
                    "pid": "24500",
                    "process_name": "sqlceip.exe",
                    "properties": [
                        {
                            "WorkDir": "C:\\WINDOWS\\system32\\"
                        },
                        {
                            "CmdLine": "-Service SQLEXPRESS"
                        },
                        {
                            "ExePath": "C:\\Program Files\\Microsoft SQL Server\\MSSQL16.SQLEXPRESS\\MSSQL\\Binn\\sqlceip.exe"
                        },
                        {
                            "ParentPid": "1680"
                        }
                    ]
                }
            ],
            "properties": [
                {
                    "mssql_instance_name": "SQLEXPRESS"
                },
                {
                    "Technologies": "MSSQL,MSSQL,DOTNET,CLR"
                },
                {
                    "pgTechnologies": ".NET,CLR,Microsoft SQL Server"
                }
            ]
        }
    ],
    "containers": []
}

@dlopes7 dlopes7 requested review from afurche and dlopes7 March 10, 2025 23:56
@dlopes7 dlopes7 merged commit 827c78b into dynatrace-extensions:main Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants