Last active
September 1, 2021 06:56
-
-
Save TharindaW/90b9c5358d828450574a81c5a24ac480 to your computer and use it in GitHub Desktop.
ApplicationMonitoring
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
implementation( | |
"io.micrometer:micrometer-core:${micrometerVersion}", | |
"io.micrometer:micrometer-registry-prometheus:${micrometerVersion}", | |
"org.springframework.boot:spring-boot-starter-actuator:${spring_boot_version}" | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
@EnableConfigurationProperties(CommonTags.class) | |
public class HubMetricsConfiguration { | |
@Bean | |
public MeterRegistryCustomizer<MeterRegistry> meterRegistryCustomizer( CommonTags tags ) { | |
return registry -> registry.config() | |
.commonTags("applicationInstance", tags.getInstanceId(), | |
"applicationName", tags.getApplicationName(), | |
"productGroup", tags.getProductGroup(), | |
"productName", tags.getProductName(), | |
"environment", tags.getServicedEnvironment()); | |
} | |
@Bean | |
public TimedAspect timedAspect(MeterRegistry registry) { | |
return new TimedAspect(registry); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HELP hub_task_seconds | |
# TYPE hub_task_seconds summary | |
hub_task_seconds_count{ applicationInstance="25005",applicationName="Hub",num_executions="0", | |
productGroup="integration",productName="Hub",servicedEnvironment="dev",type="OrderAssignedToLager",action="SyncBack" } 1.0 | |
hub_task_seconds_sum { | |
applicationInstance="25005", | |
applicationName="Hub", | |
num_executions="0", | |
productGroup="integration", | |
productName="Hub", | |
servicedEnvironment="dev", | |
type="X" | |
action="SyncBack" } 1.786964501 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private final MeterRegistry meterRegistry; | |
@Timed( | |
value = "hub.task.histo", | |
histogram = true, | |
percentiles = {0.5, 0.90, 0.95}, | |
extraTags = { | |
"type", "all", | |
"action", "all" | |
} | |
) | |
public TaskExecution execute(Task task) { | |
task.setUuid(UUID.randomUUID()); | |
TaskEntity domain = mapper.mapToDomain(task); | |
return meterRegistry.timer("hub.task", | |
"type", api.getType(), | |
"action", api.getAction(), | |
"num_executions", String.valueOf(domain.getNumExecutions())) | |
.record(() -> execute(task, domain.asRunning())); | |
} | |
private TaskExecution execute(Task api, TaskEntity domain) { | |
//Make your BL magic here | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring: | |
application: | |
name: Sync-Hub | |
management: | |
endpoints: | |
web: | |
exposure: | |
include: health,status,info,metrics,prometheus | |
metrics: | |
tags: | |
application: ${spring.application.name} | |
productGroup: integration | |
productName: Hub | |
servicedEnvironment: dev | |
enable: | |
tomcat: true | |
hikaricp: true | |
jvm: true | |
jvm.memory: true | |
jvm.gc.pause: true | |
jdbc: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scrape_configs: | |
- job_name: Hub | |
honor_timestamps: true | |
scrape_interval: 5s | |
scrape_timeout: 5s | |
metrics_path: actuator/prometheus | |
scheme: http | |
static_configs: | |
- targets: | |
- localhost:25005 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment