spring-boot-admin icon indicating copy to clipboard operation
spring-boot-admin copied to clipboard

Auto-closing OpsGenie alerts fails due to missing identifierType parameter

Open AE-RobertMcDonnell opened this issue 1 year ago • 4 comments

Spring Boot Admin Server information

  • Version: v3.5.1

  • Spring Boot version: v3.5.3

  • Configured Security: basic auth

  • Webflux or Servlet application: WebFlux

Client information

  • Spring Boot versions: v3.5.3

  • Used discovery mechanism: eureka

  • Webflux or Servlet application: WebFlux

Description

While I was successful in getting Spring Boot Admin to create OpsGenie alerts when my app instances state changes, these alerts are not automatically closing when I bring the instance back up.

I can see in the Spring Boot Admin logs that it is attempting to close the alert, and I can see that it is receiving a 202 ACCEPTED response from OpsGenie, however, the alert remains open.

After turning up the logging level for RestTemplate, I can see the close happen: 2025-08-07 11:18:32,981 DEBUG o.s.c.l.CompositeLog [reactor-http-nio-1] HTTP POST https://api.opsgenie.com/v2/alerts/myapp_870c2b816861/close 2025-08-07 11:18:32,983 DEBUG o.s.c.l.CompositeLog [reactor-http-nio-1] Accept=[application/json, application/*+json] 2025-08-07 11:18:32,984 DEBUG o.s.c.l.CompositeLog [reactor-http-nio-1] Writing [{source=my-source}] as "application/json" 2025-08-07 11:18:33,171 DEBUG o.s.c.l.CompositeLog [reactor-http-nio-1] Response 202 ACCEPTED

I tried manually POSTing to OpsGenie using the URL and details above, but the result was the same. Then after some googling, I discovered that the OpsGenie Rest API needs an identifierType parameter to be sent. If you don't send this parameter it will assume an identifierType of "id". However, SBA is passing in the alias to close, and not the id, so the close fails.

If I manually POST to the url https://api.opsgenie.com/v2/alerts/myapp_870c2b816861/close?identifierType=alias then the close happens.

Looking at the de.codecentric.boot.admin.server.notify.OpsGenieNotifier class code, I can see where it is building the close URL and that it is not setting identifierType:

protected String buildUrl(InstanceEvent event, Instance instance) { if ((event instanceof InstanceStatusChangedEvent statusChangedEvent) && (StatusInfo.STATUS_UP.equals(statusChangedEvent.getStatusInfo().getStatus()))) { return String.format("%s/%s/close", url, generateAlias(instance)); } return url.toString(); }

Is there any way to force it to set the identifierType to alias?

Thank you!

AE-RobertMcDonnell avatar Aug 07 '25 15:08 AE-RobertMcDonnell

Hi @AE-RobertMcDonnell as you have analyzed this already down to the line where it should be fixed - can you just provide a PR with fix?

erikpetzold avatar Aug 08 '25 06:08 erikpetzold

Hi @AE-RobertMcDonnell as you have analyzed this already down to the line where it should be fixed - can you just provide a PR with fix?

Absolutely!

Here is the PR: https://github.com/codecentric/spring-boot-admin/pull/4557

Please let me know if there

AE-RobertMcDonnell avatar Aug 08 '25 16:08 AE-RobertMcDonnell

Oops, I hadn't intended to close the issue out...

AE-RobertMcDonnell avatar Aug 08 '25 16:08 AE-RobertMcDonnell

Hi, I’d like to work on this issue. I can reproduce the problem and will submit a PR with a fix.

yashdotdev13 avatar Aug 10 '25 05:08 yashdotdev13