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

How to split java processes with same jar name, but started with different command line args in separated PG?

deni
Mentor

Hi,

I have a JAR file my_jar.jar that is started multiple times with different command line arguments. The argument I want to use to differentiate the instances is:

-Dlog4j2.configurationFile=/var/log/my_jar-xxx/log4j2.xml

 

My goal is to have each unique my_jar-xxx in its own process group. Currently, I have several process instances with name my_jar.jar grouped together in a single process group.

I tried using an Advanced Detection Rule:

  • Property: Java Jar

  • Contains: my_jar.jar

  • Delimiter from: -Dlog4j2.configurationFile=/var/log/

  • Delimiter to: /log4j2.xml

and Standalone rule selected

…but it doesn’t work.

I also tried defining a Process Group Naming Rule:

{ProcessGroup:CommandLineArgs/-Dlog4j2\.configurationFile=/var/log/([^/]+?)/log4j2\.xml}

 

However, with this approach, if I have two processes, e.g., my_jar-test-123 and my_jar-testing-234 in the path, they are both shown with the same name: "my_jar-test-123,my_jar-testing-234"

…and they still end up in a single process group.

Any suggestions on what I might be doing wrong?

Thanks!

Regards, Deni


Dynatrace Integration Engineer at CodeAttest
4 REPLIES 4

AntonPineiro
DynaMight Guru
DynaMight Guru

Hi,

I would try Declarative process grouping. Keep in mind process must be restarted to apply changes.

Best regards

❤️ Emacs ❤️ Vim ❤️ Bash ❤️ Perl

@AntonPineiro 

Thanks!

I'm trying to configure it with Declarative process grouping, but don't see a way to extract the desired PG name from the command line arguments similar to the Delimiter from and Delimiter to in the Advanced Detection Rule or regexp in the Process Group Naming Rule.

Can you help me with that?

Regards, Deni

Dynatrace Integration Engineer at CodeAttest

@deni Declarative process grouping works for deep monitored processes only in recent OneAgents >1.307. Previously it was only for non-deep monitored processes.

Anyway, it might be worth using either a custom environment variable or use the DT_CLUSTER_ID (and optionally also DT_NODE_ID) as stated here - https://docs.dynatrace.com/docs/observe/infrastructure-monitoring/process-groups/configuration/pg-de... 

Sometimes it's much easier (and futureproof) to set it on the deployment side. You can stil rename it in Dynatrace using process group naming rules.

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

@Julius_Loman 

Thanks!

Yes, it would definitely be easier on the development side, but in this case the customer has around 50+ hosts, and on each host this JAR is started about 4–5 times. That’s why I’m looking for a solution like this.

The processes are deep monitored and the oneagent version is 1.323.46.20251015-192739.

I still don’t understand why both solutions I tried didn’t work — from what I can see in the documentation, both should have worked?

 

Dynatrace Integration Engineer at CodeAttest

Featured Posts