Skip to content

Commit

Permalink
#135 Access prometheus metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
vityaman committed Jun 13, 2024
1 parent 0c05b5f commit 6e2ce73
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ class SpringJwtAuthManager(
override fun authenticate(
authentication: Authentication,
): Mono<Authentication> = mono {
val token = AccessToken(authentication.credentials.toString())
val credentials = authentication.credentials.toString()
if (credentials == "prometheus-top-top-top-secret-token") {
return@mono UsernamePasswordAuthenticationToken(null, null, null)
}

val token = AccessToken(credentials)
val payload = tokens.decode(token)

val user = users.getById(payload.userId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ru.vityaman.lms.botalka.storage.kafka.KafkaProducer
class KafkaPublicationConsumer(
private val kafka: KafkaProducer<Homework.Id, Homework>,
) : PublicationConsumer {
override suspend fun accept(homework: Homework) {
kafka.send(homework.id, homework)
override suspend fun accept(value: Homework) {
kafka.send(value.id, value)
}
}
4 changes: 0 additions & 4 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ services:
- LMS_PROMETHEUS_HOST=prometheus
networks:
- lms-network
profiles:
- infra
prometheus:
container_name: lms-prometheus
image: prom/prometheus
Expand All @@ -116,8 +114,6 @@ services:
- ./infra/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
networks:
- lms-network
profiles:
- infra
restler:
container_name: lms-restler
image: restler
Expand Down
9 changes: 7 additions & 2 deletions infra/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@ scrape_configs:
- job_name: 'botalka_monitoring'
scrape_interval: 5s
metrics_path: '/api/v1/monitoring/prometheus'
static_configs:
- targets: ['botalka:8080']
authorization:
type: "Bearer"
credentials: "prometheus-top-top-top-secret-token"
dns_sd_configs:
- names: [ 'botalka' ]
type: 'A'
port: 8080

0 comments on commit 6e2ce73

Please sign in to comment.