Kim S. avatar image
Kim S. asked ·

How to get an agent names through a Plug-In from incidents

Customer wants to make a plug-in which is taken agent names from incidents on DT.

There is usually shown agent name from incidents, here they tried to get it though Plug-In, however, they could not get agent names even though they could get some messages through Plug-In from incidents.

If they want make a Plug-in which is able to get agent names from incidents defined, how they can get agent names from incidents ?

they expect to have 20 incidents to be defined for 56 JVMs and 14 web servers

Below is their source ;


public Status execute(ActionEnvironment env) throws Exception {

Status status = new Status();

LogFileWriter writer;


if(isSMB) {

writer = new LogFileWriter(folder, fileName, user_name, password);

}else {

writer = new LogFileWriter(folder, fileName);



Collection<Incident> incidents = env.getIncidents();

for (Incident incident : incidents) {

String message = incident.getMessage();

String time = incident.getStartTime().toString();

String profileStr = incident.getKey().toString();

String matcher = "systemProfile=";



int firstInt = profileStr.indexOf(matcher);

int endInt = profileStr.indexOf("]");


String proFile;


proFile = profileStr.substring(firstInt + matcher.length(),endInt);


status = writer.writeLog(message, changeFormat(time), log1, proFile, incidentLevel.substring(0, 1));


log.log(Level.INFO, "Host = " + env.getHost());

log.log(Level.INFO, "System Profile = " + env.getSystemProfileName());


log.log(Level.INFO, "Message = " + message);

log.log(Level.INFO, "Start Time = " + time);

log.log(Level.INFO, "Profile = " + proFile);


Collection<PurePath> purepaths = incident.getPurePaths();

for(PurePath purePath : purepaths) {

log.log(Level.INFO, "Agent ID = " + purePath.getAgentId());




return status;


10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

1 Answer

Eugene T. avatar image
Eugene T. answered ·

Hi Sanghyun,

The com.dynatrace.diagnostics.pdk.Incident interface contains Collection of violations referenced by the Incident.getViolations() method. Each com.dynatrace.diagnostics.pdk.Violation, i.e. each object which implements the com.dynatrace.diagnostics.pdk.Violation, contains reference to the com.dynatrace.diagnostics.pdk.Source of violation. Object which implements the com.dynatrace.diagnostics.pdk.Source interface can be one of the following 5 types:

  1. com.dynatrace.diagnostics.pdk.AgentSource;
  2. com.dynatrace.diagnostics.pdk.AgentGroupSource;
  3. com.dynatrace.diagnostics.pdk.MonitorSource;
  4. com.dynatrace.diagnostics.pdk.CollectorSource;
  5. com.dynatrace.diagnostics.pdk.ServerSource.

The com.dynatrace.diagnostics.pdk.AgentSource.getName() method returns name of the agent which is a source of the violation that triggered incident.

Please let me know if you have any further questions.


10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.