Skip to content

Commit

Permalink
Prometheus
Browse files Browse the repository at this point in the history
  • Loading branch information
magnusev committed Apr 30, 2021
1 parent c0f8e7e commit ebe5d6e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ repositories {
}

val ktor_version = "1.5.0"
val prometheusVersion = "1.6.6"
val exposed_version = "0.17.13"
val coroutines_version = "1.4.3"

Expand Down Expand Up @@ -59,6 +60,8 @@ dependencies {
// KTor stuff
implementation("io.ktor:ktor-server-core:$ktor_version")
implementation("io.ktor:ktor-server-netty:$ktor_version")
implementation("io.ktor", "ktor-metrics-micrometer", ktor_version)
implementation("io.micrometer", "micrometer-registry-prometheus", prometheusVersion)

// Database stuff
implementation("org.postgresql:postgresql:$postgresql_version")
Expand Down
20 changes: 19 additions & 1 deletion nais-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,22 @@ metadata:
labels:
team: pto
spec:
image: ghcr.io/navikt/veilarbvarsel/veilarbvarsel:{{version}}
image: ghcr.io/navikt/veilarbvarsel/veilarbvarsel:{{version}}
port: 8080
prometheus:
enabled: true
path: /metrics
liveness:
path: /system/isAlice
port: 8080
initialDelay: 10
timeout: 10
readyness:
path: /system/isReady
port: 8080
initialDelay: 10
timeout: 10
replicas:
min: 1
max: 2
cpuThreasholdPercentage: 50
26 changes: 22 additions & 4 deletions src/main/kotlin/no/nav/fo/veilarbvarsel/main.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package no.nav.fo.veilarbvarsel

import io.ktor.application.*
import io.ktor.metrics.micrometer.*
import io.ktor.response.*
import io.ktor.routing.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
import io.micrometer.core.instrument.binder.jvm.JvmGcMetrics
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics
import io.micrometer.core.instrument.binder.system.ProcessorMetrics
import io.micrometer.prometheus.PrometheusConfig
import io.micrometer.prometheus.PrometheusMeterRegistry
import no.nav.fo.veilarbvarsel.domain.VarselType
import no.nav.fo.veilarbvarsel.features.BackgroundJob
import no.nav.fo.veilarbvarsel.kafka.internal.InternalEventProducer
import no.nav.fo.veilarbvarsel.kafka.internal.KafkaInternalConsumer
import no.nav.fo.veilarbvarsel.system.systemRouter
import no.nav.fo.veilarbvarsel.varsel.VarselSender
import no.nav.fo.veilarbvarsel.varsel.VarselServiceImpl
import org.slf4j.LoggerFactory
import java.util.*

Expand All @@ -23,6 +26,18 @@ fun main() {
}

fun Application.server() {
val appMicrometerRegistry = PrometheusMeterRegistry(PrometheusConfig.DEFAULT)

install(MicrometerMetrics) {
registry = appMicrometerRegistry

meterBinders = listOf(
JvmMemoryMetrics(),
JvmGcMetrics(),
ProcessorMetrics()
)
}

/* DB.connect()
DB.setupSchemas()
Expand All @@ -40,6 +55,9 @@ fun Application.server() {
trace {
application.log.debug(it.buildText())
}
get("/metrics") {
call.respond(appMicrometerRegistry.scrape())
}
systemRouter()
}

Expand Down

0 comments on commit ebe5d6e

Please sign in to comment.