Skip to content

feat: add serverName variable on alert template#259

Merged
tonygermano merged 1 commit intoOpenIntegrationEngine:mainfrom
kryskool:add-alert-servername
Mar 14, 2026
Merged

feat: add serverName variable on alert template#259
tonygermano merged 1 commit intoOpenIntegrationEngine:mainfrom
kryskool:add-alert-servername

Conversation

@kryskool
Copy link
Contributor

@kryskool kryskool commented Mar 5, 2026

Ref #258

@kryskool kryskool force-pushed the add-alert-servername branch from cbb6267 to 8d42d1d Compare March 5, 2026 18:46
@github-actions
Copy link

github-actions bot commented Mar 6, 2026

Test Results

  105 files  ±0    202 suites  ±0   7m 0s ⏱️ + 1m 9s
  633 tests ±0    633 ✅ ±0  0 💤 ±0  0 ❌ ±0 
1 266 runs  ±0  1 266 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 9a36030. ± Comparison against base commit 0f0d8a4.

♻️ This comment has been updated with latest results.

Copy link
Member

@tonygermano tonygermano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a reasonable change.

For other reviewers, there are also variables added here

public List<String> getVariables() {
List<String> variables = new ArrayList<String>();
variables.add("systemTime");
variables.add("error");
variables.add("errorMessage");
variables.add("errorType");
variables.add("channelId");
variables.add("channelName");
variables.add("connectorName");
variables.add("connectorType");
variables.add("messageId");
return variables;
}

and context here

context.put("systemTime", String.valueOf(errorEvent.getDateTime()));
context.put("channelId", channelId);
context.put("channelName", channelName);
context.put("connectorName", errorEvent.getConnectorName());
context.put("connectorType", errorEvent.getConnectorType());
context.put("error", fullErrorMessage);
context.put("errorMessage", (errorEvent.getThrowable() == null) ? "No exception message." : errorEvent.getThrowable().getMessage());
context.put("errorType", errorEvent.getType());
if (errorEvent.getMessageId() != null) {
context.put("messageId", errorEvent.getMessageId());
}

The changes in the PR appear to be in the correct place since they are added to the location for the "global" values, whereas the sections above look to be for trigger specific values.

However, care seems to be taken to not add null values to the context for variables which can possibly be null. The first time I tested the changes in this PR it did not replace the velocity token because I did not have a server name set, but it was not immediately clear that was the reason. I could see people who are unaware that the setting exists thinking that this should report the server's hostname. I wonder what other's thoughts are on taking the approach of the errorMessage variable above, and using a "Server Name not configured" value when the server name is null or empty.

@tonygermano tonygermano requested review from a team, NicoPiel, gibson9583, jonbartels, kayyagari, kpalang, ssrowe and tonygermano and removed request for a team March 9, 2026 03:59
@gibson9583
Copy link
Contributor

My preference would be to leave the token behind when server isn't configure, but we'd be deviating from the existing pattern only found in Alerts. I'm ok with either path with the rationale being to keep consistency in alerts. I think there is justification for either, but then it'd be weird errorMessage behaves one way.

@kryskool
Copy link
Contributor Author

Hi @tonygermano

Thanks for the review, i can check if value is null or empty and replace with text "ServerName not defined" if it's a reasonable fix ?

@tonygermano
Copy link
Member

Hi @tonygermano

Thanks for the review, i can check if value is null or empty and replace with text "ServerName not defined" if it's a reasonable fix ?

I'm agreeable to that, but I was trying to get consensus from the other maintainers if that's the direction we want to go or if it should stay as you originally submitted it. What is your opinion?

@kpalang
Copy link
Contributor

kpalang commented Mar 11, 2026

Hi @tonygermano
Thanks for the review, i can check if value is null or empty and replace with text "ServerName not defined" if it's a reasonable fix ?

I'm agreeable to that, but I was trying to get consensus from the other maintainers if that's the direction we want to go or if it should stay as you originally submitted it. What is your opinion?

I'm leaning on keeping the variable empty if no server name is set. "Empty" is already a good default, and it gives a good indicator to set one if none are set.

I could see people who are unaware that the setting exists thinking that this should report the server's hostname.

I'd like to think hostname is an industry specific term vs a "server name", but I can also see how it could be mixed up. I would leave it up to the user to know the difference.

Signed-off-by: Christophe Chauvet <christophe.chauvet@gmail.com>
@tonygermano tonygermano force-pushed the add-alert-servername branch from 8d42d1d to 9a36030 Compare March 13, 2026 21:36
Copy link
Member

@tonygermano tonygermano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I just realized when seeing the results of the co-pilot review Sean kicked off two days ago that this is actually a partial duplicate of #47 , which adds serverName and environmentName. It couldn't be merged at the time that it was opened because it required at least java 9, and we had not upgraded from java 8 to 17 yet.

In regard to the question I had asked above, I verified that the internal value can't actually be an empty string, only null. I tested this by

  • starting a new instance
  • setting values for both fields in the ui and saving
  • checking the new values were being used
  • clearing the values in the ui and saving
  • verifying the internal values were set back to null rather than an empty string

Attempting to use null values in the template results in the token remaining in the output and not being replaced rather than showing an empty value.

PR #47 already addresses this by inserting an empty string into the alert velocity context for serverName or environmentName if either of them are null. As far as I can tell, that seems to be an acceptable solution for everyone who has already commented on this PR.

I'm going to merge this one as it is since most of the discussion has happened here, and then we'll get the other one applied on top of it.

@tonygermano tonygermano merged commit 9a36030 into OpenIntegrationEngine:main Mar 14, 2026
4 checks passed
@tonygermano tonygermano linked an issue Mar 14, 2026 that may be closed by this pull request
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.

[IDEA] serverName not available on alert template

5 participants