Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions exporter/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
kotlin("jvm")
kotlin("plugin.spring")
kotlin("plugin.jpa") version "1.9.24"
id("org.springframework.boot")
id("io.spring.dependency-management")
}
Expand All @@ -11,10 +12,16 @@ java {
}
}

repositories {
mavenCentral()
}

dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
runtimeOnly("com.mysql:mysql-connector-j")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("io.micrometer:micrometer-core")
implementation("com.zaxxer:HikariCP")
Expand Down Expand Up @@ -42,3 +49,9 @@ tasks.withType<org.jlleitschuh.gradle.ktlint.tasks.GenerateReportsTask> {
enabled = false
}
}

allOpen {
annotation("jakarta.persistence.Entity")
annotation("jakarta.persistence.MappedSuperclass")
annotation("jakarta.persistence.Embeddable")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package lab.monilabexporterex.api

import lab.monilabexporterex.api.dto.GcMetricResponse
import lab.monilabexporterex.service.MetricService
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/gc")
class MetricController(
private val metricService: MetricService,
) {

@GetMapping("/metric")
fun getGcMetrics(): ResponseEntity<List<GcMetricResponse>> {
val data = metricService.getAllGcMetrics()
return ResponseEntity.ok(data)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package lab.monilabexporterex.api.dto

data class GcMetricResponse(
val id: Long,
val label: String,
val count: Long,
val time: Long,
val pause: Long,
val allocationRate: Double,
val liveDataSize: Long,
val gcStrategy: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package lab.monilabexporterex.model

import jakarta.persistence.*

@Entity
@Table(name = "tb_metric_application")
class ApplicationEntity(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
val id: Long = 0,

@Enumerated(EnumType.STRING)
@Column(name = "label", nullable = false, length = 10)
val label: Label,

@Column(name = "http_requests_count", nullable = false)
val httpRequestsCount: Long,

@Column(name = "http_latency", nullable = false)
val httpLatency: Double,

@Column(name = "db_connections_active", nullable = false)
val dbConnectionsActive: Int,

@Column(name = "db_connections_max", nullable = false)
val dbConnectionsMax: Int,

@Column(name = "queue_tasks_pending", nullable = false)
val queueTasksPending: Int,

@Lob
@Column(name = "custom_metrics", columnDefinition = "TEXT", nullable = false)
val customMetrics: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package lab.monilabexporterex.model

import jakarta.persistence.*

@Entity
@Table(name = "tb_metric_class_loading")
class ClassLoadingInfoEntity(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
val id: Long = 0,

@Enumerated(EnumType.STRING)
@Column(name = "label", nullable = false, length = 10)
val label: Label,

@Column(name = "loaded", nullable = false)
val loaded: Int,

@Column(name = "unloaded", nullable = false)
val unloaded: Long,

@Column(name = "code_cache_used", nullable = false)
val codeCacheUsed: Long,

@Column(name = "code_cache_max", nullable = false)
val codeCacheMax: Long,

@Column(name = "compilation_time", nullable = false)
val compilationTime: Long,

@Column(name = "reserved_code_cache_size", nullable = false)
val reservedCodeCacheSize: Long,
)
34 changes: 34 additions & 0 deletions exporter/src/main/kotlin/lab/monilabexporterex/model/CpuEntity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package lab.monilabexporterex.model

import jakarta.persistence.*

@Entity
@Table(name = "tb_metric_cpu")
class CpuEntity(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
val id: Long = 0,

@Enumerated(EnumType.STRING)
@Column(name = "label", nullable = false, length = 10)
val label: Label,

@Column(name = "process_usage", nullable = false)
val processUsage: Double,

@Column(name = "system_usage", nullable = false)
val systemUsage: Double,

@Column(name = "uptime", nullable = false)
val uptime: Long,

@Column(name = "start_time", nullable = false)
val startTime: Long,

@Column(name = "load_average", nullable = false)
val loadAverage: Double,

@Column(name = "open_fds", nullable = false)
val openFds: Long,
)
34 changes: 34 additions & 0 deletions exporter/src/main/kotlin/lab/monilabexporterex/model/GcEntity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package lab.monilabexporterex.model

import jakarta.persistence.*

@Entity
@Table(name = "tb_metric_gc")
class GcEntity(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
val id: Long = 0,

@Enumerated(EnumType.STRING)
@Column(name = "label", nullable = false, length = 10)
val label: Label,

@Column(name = "count", nullable = false)
val count: Long,

@Column(name = "time", nullable = false)
val time: Long,

@Column(name = "pause", nullable = false)
val pause: Long,

@Column(name = "allocation_rate", nullable = false)
val allocationRate: Double,

@Column(name = "live_data_size", nullable = false)
val liveDataSize: Long,

@Column(name = "gc_strategy", nullable = false)
val gcStrategy: String,
)
5 changes: 5 additions & 0 deletions exporter/src/main/kotlin/lab/monilabexporterex/model/Label.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package lab.monilabexporterex.model

enum class Label {
TEST, TRAIN
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package lab.monilabexporterex.model

import jakarta.persistence.*

@Entity
@Table(name = "tb_metric_memory")
class MemoryEntity(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
val id: Long = 0,

@Enumerated(EnumType.STRING)
@Column(name = "label", nullable = false)
val label: Label,

@Column(name = "used", nullable = false)
val used: Long,

@Column(name = "max", nullable = false)
val max: Long,

@Column(name = "committed", nullable = false)
val committed: Long,

@Column(name = "eden", nullable = false)
val eden: Long,

@Column(name = "survivor", nullable = false)
val survivor: Long,

@Column(name = "old", nullable = false)
val old: Long,

@Column(name = "buffer_pool_used", nullable = false)
val bufferPoolUsed: Long,

@Column(name = "max_direct_memory_size", nullable = false)
val maxDirectMemorySize: Long,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package lab.monilabexporterex.model

import jakarta.persistence.*

@Entity
@Table(name = "tb_metric_network")
class NetworkEntity(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
val id: Long = 0,

@Enumerated(EnumType.STRING)
@Column(name = "label", nullable = false, length = 10)
val label: Label,

@Column(name = "bytes_sent", nullable = false)
val bytesSent: Long,

@Column(name = "bytes_received", nullable = false)
val bytesReceived: Long,

@Column(name = "tcp_connections", nullable = false)
val tcpConnections: Int,

@Column(name = "tcp_established", nullable = false)
val tcpEstablished: Int,

@Column(name = "open_sockets", nullable = false)
val openSockets: Int,

@Column(name = "prefer_ipv4", nullable = false)
val preferIPv4: Boolean,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package lab.monilabexporterex.model

import jakarta.persistence.*

@Entity
@Table(name = "tb_metric_threads")
class ThreadsEntity(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
val id: Long = 0,

@Enumerated(EnumType.STRING)
@Column(name = "label", nullable = false, length = 10)
val label: Label,

@Column(name = "count", nullable = false)
val count: Int,

@Column(name = "daemon_count", nullable = false)
val daemonCount: Int,

@Column(name = "peak_count", nullable = false)
val peakCount: Int,

@Column(name = "deadlocked_count", nullable = false)
val deadlockedCount: Int,

@Column(name = "cpu_time", nullable = false)
val cpuTime: Long,

@Lob
@Column(name = "states", columnDefinition = "TEXT", nullable = false)
val states: String,
)
Loading