Skip to content

Commit

Permalink
Merge branch 'main' into vlad.diachenko/bloom-compactor_downloading-c…
Browse files Browse the repository at this point in the history
…hunks-in-batches
  • Loading branch information
vlad-diachenko authored Jan 12, 2024
2 parents a97a9e4 + 5517eaa commit 3ef9d53
Show file tree
Hide file tree
Showing 56 changed files with 2,137 additions and 834 deletions.
1 change: 1 addition & 0 deletions .drone/drone.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ local build_image_tag = '0.33.0';
'GIT_TARGET_BRANCH="$DRONE_TARGET_BRANCH"',
]) { depends_on: ['loki'], when: onPRs },
make('validate-example-configs', container=false) { depends_on: ['loki'] },
make('validate-dev-cluster-config', container=false) { depends_on: ['loki'] },
make('check-example-config-doc', container=false) { depends_on: ['clone'] },
{
name: 'build-docs-website',
Expand Down
9 changes: 8 additions & 1 deletion .drone/drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,13 @@ steps:
environment: {}
image: grafana/loki-build-image:0.33.0
name: validate-example-configs
- commands:
- make BUILD_IN_CONTAINER=false validate-dev-cluster-config
depends_on:
- loki
environment: {}
image: grafana/loki-build-image:0.33.0
name: validate-dev-cluster-config
- commands:
- make BUILD_IN_CONTAINER=false check-example-config-doc
depends_on:
Expand Down Expand Up @@ -2106,6 +2113,6 @@ kind: secret
name: gpg_private_key
---
kind: signature
hmac: 30f2fb121d8271e00dc2ae8fe83a32e0e22fd2bd268609d0c3f295033fcd4fb6
hmac: fe7669a21410ae5f2d1ad6b6205fdc582af874f65f7bd6a679731a88174e3a1c

...
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

##### Enhancements

* [11571](https://github.com/grafana/loki/pull/11571) **MichelHollands**: Add a metrics.go log line for requests from querier to ingester
* [11633](https://github.com/grafana/loki/pull/11633) **cyriltovena**: Add profiling integrations to tracing instrumentation.
* [11571](https://github.com/grafana/loki/pull/11571) **MichelHollands**: Add a metrics.go log line for requests from querier to ingester
* [11477](https://github.com/grafana/loki/pull/11477) **MichelHollands**: support GET for /ingester/shutdown
* [11363](https://github.com/grafana/loki/pull/11363) **kavirajk**: bugfix(memcached): Make memcached batch fetch truely context aware.
* [11319](https://github.com/grafana/loki/pull/11319) **someStrangerFromTheAbyss**: Helm: Add extraContainers to the write pods.
Expand Down Expand Up @@ -46,6 +47,8 @@
* [11539](https://github.com/grafana/loki/pull/11539) **kaviraj,ashwanthgoli** Support caching /series and /labels query results
* [11545](https://github.com/grafana/loki/pull/11545) **dannykopping** Force correct memcached timeout when fetching chunks.
* [11589](https://github.com/grafana/loki/pull/11589) **ashwanthgoli** Results Cache: Adds `query_length_served` cache stat to measure the length of the query served from cache.
* [11535](https://github.com/grafana/loki/pull/11535) **dannykopping** Query Frontend: Allow customisable splitting of queries which overlap the `query_ingester_within` window to reduce query pressure on ingesters.
* [11654](https://github.com/grafana/loki/pull/11654) **dannykopping** Cache: atomically check background cache size limit correctly.

##### Fixes
* [11074](https://github.com/grafana/loki/pull/11074) **hainenber** Fix panic in lambda-promtail due to mishandling of empty DROP_LABELS env var.
Expand All @@ -54,6 +57,8 @@
* [11551](https://github.com/grafana/loki/pull/11551) **dannykopping** Do not reflect label names in request metrics' "route" label.
* [11601](https://github.com/grafana/loki/pull/11601) **dannykopping** Ruler: Fixed a panic that can be caused by concurrent read-write access of tenant configs when there are a large amount of rules.
* [11606](https://github.com/grafana/loki/pull/11606) **dannykopping** Fixed regression adding newlines to HTTP error response bodies which may break client integrations.
* [11657](https://github.com/grafana/loki/pull/11657) **ashwanthgoli** Log results cache: compose empty response based on the request being served to avoid returning incorrect limit or direction.
* [11587](https://github.com/grafana/loki/pull/11587) **trevorwhitney** Fix semantics of label parsing logic of metrics and logs queries. Both only parse the first label if multiple extractions into the same label are requested.

##### Changes

Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,9 @@ EXAMPLES_SKIP_VALIDATION_FLAG := "doc-example:skip-validation=true"
validate-example-configs: loki
for f in $$(grep -rL $(EXAMPLES_SKIP_VALIDATION_FLAG) $(EXAMPLES_YAML_PATH)/*.yaml); do echo "Validating provided example config: $$f" && ./cmd/loki/loki -config.file=$$f -verify-config || exit 1; done

validate-dev-cluster-config: loki
./cmd/loki/loki -config.file=./tools/dev/loki-boltdb-storage-s3/config/loki.yaml -verify-config

# Dynamically generate ./docs/sources/configure/examples.md using the example configs that we provide.
# This target should be run if any of our example configs change.
generate-example-config-doc:
Expand Down
6 changes: 5 additions & 1 deletion cmd/loki/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (

"github.com/go-kit/log/level"
"github.com/grafana/dskit/log"
"github.com/grafana/dskit/spanprofiler"
"github.com/grafana/dskit/tracing"
"github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/version"

Expand Down Expand Up @@ -84,7 +86,9 @@ func main() {
if err != nil {
level.Error(util_log.Logger).Log("msg", "error in initializing tracing. tracing will not be enabled", "err", err)
}

if config.Tracing.ProfilingEnabled {
opentracing.SetGlobalTracer(spanprofiler.NewTracer(opentracing.GlobalTracer()))
}
defer func() {
if trace != nil {
if err := trace.Close(); err != nil {
Expand Down
6 changes: 6 additions & 0 deletions docs/sources/configure/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2884,6 +2884,12 @@ The `limits_config` block configures global and per-tenant limits in Loki.
# CLI flag: -querier.split-metadata-queries-by-interval
[split_metadata_queries_by_interval: <duration> | default = 1d]

# Interval to use for time-based splitting when a request is within the
# `query_ingesters_within` window; defaults to `split-queries-by-interval` by
# setting to 0.
# CLI flag: -querier.split-ingester-queries-by-interval
[split_ingester_queries_by_interval: <duration> | default = 0s]

# Limit queries that can be sharded. Queries within the time range of now and
# now minus this sharding lookback are not sharded. The default value of 0s
# disables the lookback, causing sharding of all queries at all times.
Expand Down
60 changes: 49 additions & 11 deletions docs/sources/send-data/fluentbit/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ weight: 500
---
# Fluent Bit client

[Fluent Bit](https://fluentbit.io/) is a fast and lightweight logs and metrics processor and forwarder that can be configured with the [Grafana Loki output plugin](https://docs.fluentbit.io/manual/pipeline/outputs/loki) to ship logs to Loki. You can define which log files you want to collect using the [`Tail`](https://docs.fluentbit.io/manual/pipeline/inputs/tail) or [`Stdin`](https://docs.fluentbit.io/manual/pipeline/inputs/standard-input) data pipeline input. Additionally, Fluent Bit supports multiple `Filter` and `Parser` plugins (`Kubernetes`, `JSON`, etc.) to structure and alter log lines.
[Fluent Bit](https://fluentbit.io/) is a fast and lightweight logs and metrics processor and forwarder that can be configured with the Grafana Fluent Bit Plugin described here or with the [Fluent-bit Loki output plugin](https://docs.fluentbit.io/manual/pipeline/outputs/loki) to ship logs to Loki.
This plugin has more configuration options compared to the built-in Fluent Bit Loki plugin.
You can define which log files you want to collect using the [`Tail`](https://docs.fluentbit.io/manual/pipeline/inputs/tail) or [`Stdin`](https://docs.fluentbit.io/manual/pipeline/inputs/standard-input) data pipeline input. Additionally, Fluent Bit supports multiple `Filter` and `Parser` plugins (`Kubernetes`, `JSON`, etc.) to structure and alter log lines.

## Usage

Expand Down Expand Up @@ -63,23 +65,59 @@ To ship logs from Docker containers to Grafana Cloud using Fluent Bit, you can u

You can run Fluent Bit as a [Daemonset](https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/) to collect all your Kubernetes workload logs.

To do so you can use our [Fluent Bit helm chart](https://github.com/grafana/helm-charts/tree/main/charts/fluent-bit):
To do so you can use the [Fluent Bit helm chart](https://github.com/fluent/helm-charts) with the following `values.yaml` changing the value of `FLUENT_LOKI_URL`:

```yaml
image:
# Here we use the Docker image which has the plugin installed
repository: grafana/fluent-bit-plugin-loki
tag: main-e2ed1c0

args:
- "-e"
- "/fluent-bit/bin/out_grafana_loki.so"
- --workdir=/fluent-bit/etc
- --config=/fluent-bit/etc/conf/fluent-bit.conf

env:
# Note that for security reasons you should fetch the credentials through a Kubernetes Secret https://kubernetes.io/docs/concepts/configuration/secret/ . You may use the envFrom for this.
- name: FLUENT_LOKI_URL
value: https://user:[email protected]/loki/api/v1/push

config:
inputs: |
[INPUT]
Name tail
Tag kube.*
Path /var/log/containers/*.log
# Be aware that local clusters like docker-desktop or kind use the docker log format and not the cri (https://docs.fluentbit.io/manual/installation/kubernetes#container-runtime-interface-cri-parser)
multiline.parser docker, cri
Mem_Buf_Limit 5MB
Skip_Long_Lines On

outputs: |
[Output]
Name grafana-loki
Match kube.*
Url ${FLUENT_LOKI_URL}
Labels {job="fluent-bit"}
LabelKeys level,app # this sets the values for actual Loki streams and the other labels are converted to structured_metadata https://grafana.com/docs/loki/latest/get-started/labels/structured-metadata/
BatchWait 1
BatchSize 1001024
LineFormat json
LogLevel info
AutoKubernetesLabels true
```

```bash
helm repo add grafana https://grafana.github.io/helm-charts
helm repo add fluent https://fluent.github.io/helm-charts
helm repo update
helm upgrade --install fluent-bit grafana/fluent-bit \
--set loki.serviceName=loki.svc.cluster.local
helm install fluent-bit fluent/fluent-bit -f values.yaml
```

By default it will collect all containers logs and extract labels from Kubernetes API (`container_name`, `namespace`, etc..).

Alternatively you can install the Loki and Fluent Bit all together using:

```bash
helm upgrade --install loki-stack grafana/loki-stack \
--set fluent-bit.enabled=true,promtail.enabled=false
```
If you also want to host your Loki instance inside the cluster install the [official Loki helm chart](https://grafana.com/docs/loki/latest/setup/install/helm/).

### AWS Elastic Container Service (ECS)

Expand Down
19 changes: 14 additions & 5 deletions integration/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,12 +479,21 @@ type Header struct {
Name, Value string
}

// RunRangeQuery runs a query and returns an error if anything went wrong
// RunRangeQuery runs a 7d query and returns an error if anything went wrong
// This function is kept to keep backwards copatibility of existing tests.
// Better use (*Client).RunRangeQueryWithStartEnd()
func (c *Client) RunRangeQuery(ctx context.Context, query string, extraHeaders ...Header) (*Response, error) {
end := c.Now.Add(time.Second)
start := c.Now.Add(-7 * 24 * time.Hour)
return c.RunRangeQueryWithStartEnd(ctx, query, start, end, extraHeaders...)
}

// RunRangeQuery runs a query and returns an error if anything went wrong
func (c *Client) RunRangeQueryWithStartEnd(ctx context.Context, query string, start, end time.Time, extraHeaders ...Header) (*Response, error) {
ctx, cancelFunc := context.WithTimeout(ctx, requestTimeout)
defer cancelFunc()

buf, statusCode, err := c.run(ctx, c.rangeQueryURL(query), extraHeaders...)
buf, statusCode, err := c.run(ctx, c.rangeQueryURL(query, start, end), extraHeaders...)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -555,11 +564,11 @@ func (c *Client) parseResponse(buf []byte, statusCode int) (*Response, error) {
return &lokiResp, nil
}

func (c *Client) rangeQueryURL(query string) string {
func (c *Client) rangeQueryURL(query string, start, end time.Time) string {
v := url.Values{}
v.Set("query", query)
v.Set("start", formatTS(c.Now.Add(-7*24*time.Hour)))
v.Set("end", formatTS(c.Now.Add(time.Second)))
v.Set("start", formatTS(start))
v.Set("end", formatTS(end))

u, err := url.Parse(c.baseURL)
if err != nil {
Expand Down
26 changes: 19 additions & 7 deletions integration/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ server:
grpc_server_max_recv_msg_size: 110485813
grpc_server_max_send_msg_size: 110485813
common:
path_prefix: {{.dataPath}}
storage:
Expand All @@ -70,14 +69,25 @@ storage_config:
store-1:
directory: {{.sharedDataPath}}/fs-store-1
boltdb_shipper:
active_index_directory: {{.dataPath}}/index
active_index_directory: {{.dataPath}}/boltdb-index
cache_location: {{.dataPath}}/boltdb-cache
tsdb_shipper:
active_index_directory: {{.dataPath}}/tsdb-index
cache_location: {{.dataPath}}/tsdb-cache
bloom_shipper:
working_directory: {{.dataPath}}/bloom-shipper
blocks_downloading_queue:
workers_count: 1
bloom_gateway:
enabled: false
bloom_compactor:
enabled: false
working_directory: {{.dataPath}}/bloom-compactor
compactor:
working_directory: {{.dataPath}}/retention
working_directory: {{.dataPath}}/compactor
retention_enabled: true
delete_request_store: store-1
Expand Down Expand Up @@ -154,14 +164,14 @@ func New(logLevel level.Value, opts ...func(*Cluster)) *Cluster {
}

resetMetricRegistry()
sharedPath, err := os.MkdirTemp("", "loki-shared-data")
sharedPath, err := os.MkdirTemp("", "loki-shared-data-")
if err != nil {
panic(err.Error())
}

overridesFile := filepath.Join(sharedPath, "loki-overrides.yaml")

err = os.WriteFile(filepath.Join(sharedPath, "loki-overrides.yaml"), []byte(`overrides:`), 0777)
err = os.WriteFile(overridesFile, []byte(`overrides:`), 0777)
if err != nil {
panic(fmt.Errorf("error creating overrides file: %w", err))
}
Expand Down Expand Up @@ -318,12 +328,12 @@ func port(addr string) string {
func (c *Component) writeConfig() error {
var err error

configFile, err := os.CreateTemp("", "loki-config")
configFile, err := os.CreateTemp("", fmt.Sprintf("loki-%s-config-*.yaml", c.name))
if err != nil {
return fmt.Errorf("error creating config file: %w", err)
}

c.dataPath, err = os.MkdirTemp("", "loki-data")
c.dataPath, err = os.MkdirTemp("", fmt.Sprintf("loki-%s-data-", c.name))
if err != nil {
return fmt.Errorf("error creating data path: %w", err)
}
Expand Down Expand Up @@ -408,6 +418,8 @@ func (c *Component) run() error {
c.configFile,
"-limits.per-user-override-config",
c.overridesFile,
"-limits.per-user-override-period",
"1s",
), flagset); err != nil {
return err
}
Expand Down
Loading

0 comments on commit 3ef9d53

Please sign in to comment.