Skip to content

Commit

Permalink
added loki statusURL
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinsonneau committed Aug 18, 2022
1 parent def552a commit 25f3820
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
8 changes: 7 additions & 1 deletion api/v1alpha1/flowcollector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,15 @@ type FlowCollectorLoki struct {
//+kubebuilder:validation:optional
// QuerierURL specifies the address of the Loki querier service, in case it is different from the
// Loki ingester URL. If empty, the URL value will be used (assuming that the Loki ingester
// and querier are int he same host).
// and querier are in the same host).
QuerierURL string `json:"querierUrl,omitempty"`

//+kubebuilder:validation:optional
// StatusURL specifies the address of the Loki /ready /metrics /config endpoints, in case it is different from the
// Loki querier URL. If empty, the QuerierURL value will be used.
// This is usefull to show error messages and some context in the frontend
StatusURL string `json:"statusUrl,omitempty"`

//+kubebuilder:default:="netobserv"
// TenantID is the Loki X-Scope-OrgID that identifies the tenant for each request.
// it will be ignored if instanceSpec is specified
Expand Down
9 changes: 8 additions & 1 deletion config/crd/bases/flows.netobserv.io_flowcollectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ spec:
description: QuerierURL specifies the address of the Loki querier
service, in case it is different from the Loki ingester URL.
If empty, the URL value will be used (assuming that the Loki
ingester and querier are int he same host).
ingester and querier are in the same host).
type: string
sendAuthToken:
default: false
Expand All @@ -1623,6 +1623,13 @@ spec:
description: StaticLabels is a map of common labels to set on
each flow
type: object
statusUrl:
description: StatusURL specifies the address of the Loki /ready
/metrics /config endpoints, in case it is different from the
Loki querier URL. If empty, the QuerierURL value will be used.
This is usefull to show error messages and some context in the
frontend
type: string
tenantID:
default: netobserv
description: TenantID is the Loki X-Scope-OrgID that identifies
Expand Down
10 changes: 9 additions & 1 deletion controllers/consoleplugin/consoleplugin_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,23 @@ func tokenPath(desiredLoki *flowsv1alpha1.FlowCollectorLoki) string {
}

func buildArgs(desired *flowsv1alpha1.FlowCollectorConsolePlugin, desiredLoki *flowsv1alpha1.FlowCollectorLoki) []string {
querierURL := querierURL(desiredLoki)
statusURL := statusURL(desiredLoki)

args := []string{
"-cert", "/var/serving-cert/tls.crt",
"-key", "/var/serving-cert/tls.key",
"-loki", querierURL(desiredLoki),
"-loki", querierURL,
"-loki-labels", strings.Join(constants.LokiIndexFields, ","),
"-loki-tenant-id", desiredLoki.TenantID,
"-loglevel", desired.LogLevel,
"-frontend-config", filepath.Join(configPath, configFile),
}

if querierURL != statusURL {
args = append(args, "-loki-status", statusURL)
}

if desiredLoki.TLS.Enable {
if desiredLoki.TLS.InsecureSkipVerify {
args = append(args, "-loki-skip-tls")
Expand Down
7 changes: 7 additions & 0 deletions controllers/consoleplugin/consoleplugin_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ func querierURL(loki *flowsv1alpha1.FlowCollectorLoki) string {
return loki.URL
}

func statusURL(loki *flowsv1alpha1.FlowCollectorLoki) string {
if loki.StatusURL != "" {
return loki.StatusURL
}
return querierURL(loki)
}

func serviceNeedsUpdate(svc *corev1.Service, desired *pluginSpec, ns string) bool {
if svc.Namespace != ns {
return true
Expand Down
9 changes: 8 additions & 1 deletion docs/FlowCollector.md
Original file line number Diff line number Diff line change
Expand Up @@ -2854,7 +2854,7 @@ Settings related to the Loki client, used as a flow store.
<td><b>querierUrl</b></td>
<td>string</td>
<td>
QuerierURL specifies the address of the Loki querier service, in case it is different from the Loki ingester URL. If empty, the URL value will be used (assuming that the Loki ingester and querier are int he same host).<br/>
QuerierURL specifies the address of the Loki querier service, in case it is different from the Loki ingester URL. If empty, the URL value will be used (assuming that the Loki ingester and querier are in the same host).<br/>
</td>
<td>false</td>
</tr><tr>
Expand All @@ -2875,6 +2875,13 @@ Settings related to the Loki client, used as a flow store.
<i>Default</i>: map[app:netobserv-flowcollector]<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>statusUrl</b></td>
<td>string</td>
<td>
StatusURL specifies the address of the Loki /ready /metrics /config endpoints, in case it is different from the Loki querier URL. If empty, the QuerierURL value will be used. This is usefull to show error messages and some context in the frontend<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>tenantID</b></td>
<td>string</td>
Expand Down

0 comments on commit 25f3820

Please sign in to comment.