Skip to content

Commit

Permalink
feat :: v2 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
HyunSu1768 committed Aug 1, 2024
1 parent 04bfb11 commit 958eb63
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class GetContainerCpuUsageService(
team = deploy.team.teamNameEn,
containerName = deploy.deployName,
serviceType = deploy.deployType,
envType = environment
envType = environment,
isV2 = deploy.isV2
),
refId = "A",
datasource = "prometheus",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class GetContainerMemoryUsageService(
team = deploy.team.teamNameEn,
containerName = deploy.deployName,
serviceType = deploy.deployType,
envType = environment
envType = environment,
isV2 = deploy.isV2
),
refId = "A",
datasource = "prometheus",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class LogService(
team = deploy.team.teamNameEn,
containerName = deploy.deployName,
serviceType = deploy.deployType,
envType = if(environment == "prod") ContainerEnvironment.prod else ContainerEnvironment.stag
envType = if(environment == "prod") ContainerEnvironment.prod else ContainerEnvironment.stag,
isV2 = deploy.isV2
),
refId = "A",
datasource = "loki",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,36 @@ object DataUtil {
}
}

fun makeLogQuery(team: String, containerName: String, serviceType: DeployType, envType: ContainerEnvironment): String {
val fullName = "${containerName}-${serviceType.toString().lowercase()}-${envType.toString().lowercase()}"
val response = "{job=\"$team-${envType.toString().lowercase()}/$fullName\"} |~ \"(?i)\" \n"
fun getFullName(
containerName: String,
serviceType: DeployType,
envType: ContainerEnvironment,
isV2: Boolean
): String {
var fullName: String
if(isV2) {
fullName = "${containerName}-${envType.toString().lowercase()}"
}
else {
fullName = "${containerName}-${serviceType.toString().lowercase()}-${envType.toString().lowercase()}"
}
return fullName
}


fun makeLogQuery(
team: String,
containerName: String,
serviceType: DeployType,
envType: ContainerEnvironment,
isV2: Boolean
): String {
val response = "{job=\"$team-${envType.toString().lowercase()}/${getFullName(containerName, serviceType, envType, isV2)}\"} |~ \"(?i)\" \n"
return response
}

fun makeCpuUsageQuery(team: String, containerName: String, serviceType: DeployType, envType: ContainerEnvironment): String {
val fullName = "${containerName}-${serviceType.toString().lowercase()}-${envType.toString().lowercase()}"
fun makeCpuUsageQuery(team: String, containerName: String, serviceType: DeployType, envType: ContainerEnvironment, isV2: Boolean): String {
val fullName = getFullName(containerName, serviceType, envType, isV2)

val namespace = "$team-${envType.toString().lowercase()}"

Expand All @@ -56,8 +78,8 @@ object DataUtil {
""".trimIndent()
}

fun makeMemoryUsageQuery(team: String, containerName: String, serviceType: DeployType, envType: ContainerEnvironment): String {
val fullName = "${containerName}-${serviceType.toString().lowercase()}-${envType.toString().lowercase()}"
fun makeMemoryUsageQuery(team: String, containerName: String, serviceType: DeployType, envType: ContainerEnvironment, isV2: Boolean): String {
val fullName = getFullName(containerName, serviceType, envType, isV2)
val namespace = "$team-${envType.toString().lowercase()}"

return """
Expand All @@ -80,8 +102,8 @@ object DataUtil {
""".trimIndent()
}

fun makeRequestCountPerMinute(team: String, containerName: String, serviceType: DeployType, envType: ContainerEnvironment, minute: Int): String {
val fullName = "${containerName}-${serviceType.toString().lowercase()}-${envType.toString().lowercase()}"
fun makeRequestCountPerMinute(team: String, containerName: String, serviceType: DeployType, envType: ContainerEnvironment, minute: Int, isV2: Boolean): String {
val fullName = getFullName(containerName, serviceType, envType, isV2)
val namespace = "$team-${envType.toString().lowercase()}"

return """
Expand Down

0 comments on commit 958eb63

Please sign in to comment.