Skip to content
Open
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
1 change: 1 addition & 0 deletions pkg/config/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Loki struct {
TokenPath string `yaml:"tokenPath,omitempty" json:"tokenPath,omitempty"`
SkipTLS bool `yaml:"skipTls,omitempty" json:"skipTls,omitempty"`
CAPath string `yaml:"caPath,omitempty" json:"caPath,omitempty"`
Status string `yaml:"status,omitempty" json:"status,omitempty"`
StatusSkipTLS bool `yaml:"statusSkipTls,omitempty" json:"statusSkipTls,omitempty"`
StatusCAPath string `yaml:"statusCaPath,omitempty" json:"statusCaPath,omitempty"`
StatusUserCertPath string `yaml:"statusUserCertPath,omitempty" json:"statusUserCertPath,omitempty"`
Expand Down
16 changes: 16 additions & 0 deletions pkg/handler/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ func getLokiNamesForPrefix(cfg *config.Loki, lokiClient httpclient.Caller, filts
}

func (h *Handlers) getLokiStatus(r *http.Request) ([]byte, int, error) {
// Check if the status was provided by the operator
if h.Cfg.Loki.Status != "" {
return []byte(h.Cfg.Loki.Status), 200, nil
}
lokiClient := newLokiClient(&h.Cfg.Loki, r.Header, true)
baseURL := strings.TrimRight(h.Cfg.Loki.GetStatusURL(), "/")
return executeLokiQuery(fmt.Sprintf("%s/%s", baseURL, "ready"), lokiClient)
Expand Down Expand Up @@ -231,6 +235,10 @@ func (h *Handlers) LokiMetrics() func(w http.ResponseWriter, r *http.Request) {
writeError(w, http.StatusBadRequest, "Loki is disabled")
return
}
if h.Cfg.Loki.Status != "" {
writeError(w, http.StatusBadRequest, "Status URL endpoints are unavailable when using LokiStack operator. Status is provided via operator conditions.")
return
}
lokiClient := newLokiClient(&h.Cfg.Loki, r.Header, true)
baseURL := strings.TrimRight(h.Cfg.Loki.GetStatusURL(), "/")

Expand All @@ -250,6 +258,10 @@ func (h *Handlers) LokiBuildInfos() func(w http.ResponseWriter, r *http.Request)
writeError(w, http.StatusBadRequest, "Loki is disabled")
return
}
if h.Cfg.Loki.Status != "" {
writeError(w, http.StatusBadRequest, "Loki status URL is not usable with Loki operator")
return
}
lokiClient := newLokiClient(&h.Cfg.Loki, r.Header, true)
baseURL := strings.TrimRight(h.Cfg.Loki.GetStatusURL(), "/")

Expand All @@ -264,6 +276,10 @@ func (h *Handlers) LokiBuildInfos() func(w http.ResponseWriter, r *http.Request)
}

func (h *Handlers) fetchLokiConfig(cl httpclient.Caller, output any) error {
if h.Cfg.Loki.Status != "" {
return fmt.Errorf("loki status url is not usable with Loki operator")
}

baseURL := strings.TrimRight(h.Cfg.Loki.GetStatusURL(), "/")

resp, _, err := executeLokiQuery(fmt.Sprintf("%s/%s", baseURL, "config"), cl)
Expand Down