Skip to content

Commit

Permalink
fix(promtail): use dynamic port for service and add grpc check (#30)
Browse files Browse the repository at this point in the history
Signed-off-by: Bruce Becker <[email protected]>
  • Loading branch information
brucellino authored May 1, 2023
1 parent af101b2 commit c059894
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
56 changes: 29 additions & 27 deletions promtail.nomad
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
variable "promtail_version" {
description = "Version of Promtail to deploy"
type = string
default = "v2.7.3"
default = "2.7.3"
}

job "promtail" {
Expand All @@ -22,12 +22,8 @@ job "promtail" {
stagger = "30s"
}
network {
port "http" {
static = 9080
}
port "grpc" {
static = 9095
}
port "http" {}
port "grpc" {}
}

service {
Expand All @@ -45,9 +41,10 @@ job "promtail" {
check {
name = "Promtail HTTP"
type = "http"
path = "/targets"
path = "/ready"
interval = "10s"
timeout = "5s"
port = "http"

check_restart {
limit = 2
Expand All @@ -57,23 +54,23 @@ job "promtail" {
}
}

// service {
// name = "promtail-grpc"
// tags = ["grpc"]
// port = "grpc"

// check {
// name = "promtail-grpc"
// grpc_service = "promtail-grpc"
// type = "grpc"
// interval = "15s"
// timeout = "5s"
// port = "grpc"
// grpc_use_tls = false
// tls_skip_verify = true
// }
service {
name = "promtail-grpc"
tags = ["grpc"]
port = "grpc"

// check {
// name = "promtail-grpc"
// grpc_service = "promtail-grpc"
// type = "grpc"
// interval = "15s"
// timeout = "5s"
// port = "grpc"
// grpc_use_tls = false
// tls_skip_verify = true
// }

// }
}

restart {
attempts = 1
Expand All @@ -83,7 +80,9 @@ job "promtail" {
}

ephemeral_disk {
size = 300
size = 11
migrate = true
sticky = true
}

task "promtail" {
Expand All @@ -97,11 +96,14 @@ job "promtail" {
}

artifact {
source = "https://github.com/grafana/loki/releases/download/v2.7.3/promtail-linux-${attr.cpu.arch}.zip"
source = "https://github.com/grafana/loki/releases/download/v${var.promtail_version}/promtail-linux-${attr.cpu.arch}.zip"
destination = "local/promtail"
mode = "file"
}

logs {
max_files = 1
max_file_size = 10
}

resources {
cpu = 60 # 500 MHz
Expand Down
6 changes: 3 additions & 3 deletions promtail.yml.tpl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
server:
log_level: info
http_listen_port: 9080
grpc_listen_port: 9095
http_listen_port: {{ env "NOMAD_PORT_http" }}
grpc_listen_port: {{ env "NOMAD_PORT_grpc" }}

positions:
filename: /data/positions.yaml

clients:
- url: http://loki-http-server.service.consul:3100/loki/api/v1/push
- url: http://{{ range service "loki-http-server" }}{{ .Address }}:{{ .Port }}/loki/api/v1/push{{ end }}

scrape_configs:
- job_name: consul
Expand Down

0 comments on commit c059894

Please sign in to comment.