gateway/config/loki.go

28 lines
575 B
Go
Raw Normal View History

2021-09-07 14:25:39 +08:00
package config
import (
"fmt"
"gateway/utils"
)
// Loki配置信息
type lokiConfig struct {
Host string
Port string
Source string
}
// InitLokiConfig 初始化Loki配置
func InitLokiConfig() {
host := utils.GetEnvVal("LOKI_HOST", "")
port := utils.GetEnvVal("LOKI_PORT", "")
source := utils.GetEnvVal("LOKI_SOURCE", "goweb")
LokiConfig = lokiConfig{Host: host, Port: port, Source: source}
}
// GetPushURL 获取组装后的日志推送接口
func (c lokiConfig) GetPushURL() string {
return fmt.Sprintf("http://%v:%v/loki/api/v1/push", c.Host, c.Port)
}