Skip to content

feat: add serverName variable on alert template#259

Open
kryskool wants to merge 1 commit intoOpenIntegrationEngine:mainfrom
kryskool:add-alert-servername
Open

feat: add serverName variable on alert template#259
kryskool wants to merge 1 commit intoOpenIntegrationEngine:mainfrom
kryskool:add-alert-servername

Conversation

@kryskool
Copy link

@kryskool kryskool commented Mar 5, 2026

Ref #258

Signed-off-by: Christophe Chauvet <christophe.chauvet@gmail.com>
@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   6m 58s ⏱️ + 1m 11s
  633 tests ±0    633 ✅ ±0  0 💤 ±0  0 ❌ ±0 
1 266 runs  ±0  1 266 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 8d42d1d. ± Comparison against base commit 7723b34.

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
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.

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.

5 participants