Skip to content

Commit

Permalink
compression added in docs and latest merge
Browse files Browse the repository at this point in the history
  • Loading branch information
EHSchmitt4395 committed Dec 2, 2024
2 parents 9b08eec + 385ac8f commit c10d025
Show file tree
Hide file tree
Showing 13 changed files with 259 additions and 336 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ Main (unreleased)
- Change processlist query to support ONLY_FULL_GROUP_BY sql_mode
- Add perf_schema quantile columns to collector

### Bugfixes
- For sharding targets during clustering, `loki.source.podlogs` now only takes into account some labels. (@ptodev)

### Bugfixes
- Fixed an issue in the `pyroscope.write` component to allow slashes in application names in the same way it is done in the Pyroscope push API (@marcsanmi)
- Fixed an issue in the `prometheus.exporter.postgres` component that would leak goroutines when the target was not reachable (@dehaansa)

- Fixed an issue in the `otelcol.exporter.prometheus` component that would set series value incorrectly for stale metrics (@YusifAghalar)
Expand All @@ -54,6 +56,8 @@ Main (unreleased)

- Fixed a race condition that could lead to a deadlock when using `import` statements, which could lead to a memory leak on `/metrics` endpoint of an Alloy instance. (@thampiotr)

- Updated `prometheus.write.queue` to fix issue with TTL comparing different scales of time. (@mattdurham)

### Other changes

- Change the stability of the `livedebugging` feature from "experimental" to "generally available". (@wildum)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ When {{< param "PRODUCT_NAME" >}} is [using clustering][], and `enabled` is set

If {{< param "PRODUCT_NAME" >}} is _not_ running in clustered mode, then the block is a no-op and `loki.source.kubernetes` collects logs from every target it receives in its arguments.

Clustering only looks at the following labels for determining the shard key:
Clustering looks only at the following labels for determining the shard key:

* `__pod_namespace__`
* `__pod_name__`
Expand Down
15 changes: 15 additions & 0 deletions docs/sources/reference/components/loki/loki.source.podlogs.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,21 @@ cluster to distribute the load of log collection between all cluster nodes.
If {{< param "PRODUCT_NAME" >}} is _not_ running in clustered mode, then the block is a no-op and
`loki.source.podlogs` collects logs based on every PodLogs resource discovered.

Clustering looks only at the following labels for determining the shard key:

* `__pod_namespace__`
* `__pod_name__`
* `__pod_container_name__`
* `__pod_uid__`
* `__meta_kubernetes_namespace`
* `__meta_kubernetes_pod_name`
* `__meta_kubernetes_pod_container_name`
* `__meta_kubernetes_pod_uid`
* `container`
* `pod`
* `job`
* `namespace`

[using clustering]: ../../../../get-started/clustering/

## Exported fields
Expand Down
14 changes: 1 addition & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ require (
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc
github.com/grafana/tail v0.0.0-20230510142333-77b18831edf0
github.com/grafana/vmware_exporter v0.0.5-beta
github.com/grafana/walqueue v0.0.0-20241118151117-77b057cbe5a2
github.com/grafana/walqueue v0.0.0-20241202135041-6ec70efeec94
github.com/hashicorp/consul/api v1.29.5
github.com/hashicorp/go-discover v0.0.0-20230724184603-e89ebd1b2f65
github.com/hashicorp/go-multierror v1.1.1
Expand Down Expand Up @@ -929,18 +929,6 @@ replace (
github.com/prometheus/node_exporter => github.com/grafana/node_exporter v0.18.1-grafana-r01.0.20231004161416-702318429731
)

// Replacing for an internal fork which allows us to observe metrics produced by the Collector.
// This is a temporary solution while a new configuration design is discussed for the collector. Related issues:
// https://github.com/open-telemetry/opentelemetry-collector/issues/7532
// https://github.com/open-telemetry/opentelemetry-collector/pull/7644
// https://github.com/open-telemetry/opentelemetry-collector/pull/7696
// https://github.com/open-telemetry/opentelemetry-collector/issues/4970
replace (
go.opentelemetry.io/collector/otelcol => github.com/grafana/opentelemetry-collector/otelcol v0.0.0-20241104164848-8ea9d0a3e17a
go.opentelemetry.io/collector/processor/batchprocessor => github.com/grafana/opentelemetry-collector/processor/batchprocessor v0.0.0-20241104164848-8ea9d0a3e17a
go.opentelemetry.io/collector/service => github.com/grafana/opentelemetry-collector/service v0.0.0-20241104164848-8ea9d0a3e17a
)

replace github.com/github/smimesign => github.com/grafana/smimesign v0.2.1-0.20220408144937-2a5adf3481d3

// Submodules.
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1881,12 +1881,6 @@ github.com/grafana/opentelemetry-collector-contrib/receiver/prometheusreceiver v
github.com/grafana/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.0.0-20240326165551-1ae1b9218b1b/go.mod h1:XVaL+FyxEWEfHkDI/X6FJgFYDA0080A1/qoOHQ43dxM=
github.com/grafana/opentelemetry-collector/featuregate v0.0.0-20240325174506-2fd1623b2ca0 h1:i/Ne0XwoRokYj52ZcSmnvuyID3h/uA91n0Ycg/grHU8=
github.com/grafana/opentelemetry-collector/featuregate v0.0.0-20240325174506-2fd1623b2ca0/go.mod h1:mm8+xyQfgDmqhyegZRNIQmoKsNnDTwWKFLsdMoXAb7A=
github.com/grafana/opentelemetry-collector/otelcol v0.0.0-20241104164848-8ea9d0a3e17a h1:6TnkhPwEjuleHfhKSw+IyC/I2cQORuEsImZZMhoodIE=
github.com/grafana/opentelemetry-collector/otelcol v0.0.0-20241104164848-8ea9d0a3e17a/go.mod h1:H/HurP0qCcwcWdDRgvTJ/FRrVLnt++agxzHvgLQn/Ew=
github.com/grafana/opentelemetry-collector/processor/batchprocessor v0.0.0-20241104164848-8ea9d0a3e17a h1:WrDY3pU4EkHsCIepUAYWt7lIfsMEPdugmYB8k6RYjMo=
github.com/grafana/opentelemetry-collector/processor/batchprocessor v0.0.0-20241104164848-8ea9d0a3e17a/go.mod h1:QLQ31rGjPuMc/nGw4rL4HzQI9F0jVAPEmC342chxoqA=
github.com/grafana/opentelemetry-collector/service v0.0.0-20241104164848-8ea9d0a3e17a h1:ZycgUSrrwtB2x1fMdLD88J2k8886/HvX1tYHlaOH/hg=
github.com/grafana/opentelemetry-collector/service v0.0.0-20241104164848-8ea9d0a3e17a/go.mod h1:VTLnax+DjHal3q7WKQO0ITjWdfPTq2txaoNRcVXYzgE=
github.com/grafana/postgres_exporter v0.15.1-0.20241105053755-e0a51174f168 h1:I7FyVTtge/3G5YHVOMDG0l4If6W+kXbFDqtzj5gCSGs=
github.com/grafana/postgres_exporter v0.15.1-0.20241105053755-e0a51174f168/go.mod h1:dMrETGkSetWByp2XGsm8g6pRVh/ibnrDxKsN4BqnGNg=
github.com/grafana/prometheus v1.8.2-0.20240514135907-13889ba362e6 h1:kih3d3M3dxAmrpFLvnIxFzWx8KMQyKxQwKgWP67C/Fg=
Expand All @@ -1907,8 +1901,8 @@ github.com/grafana/tail v0.0.0-20230510142333-77b18831edf0 h1:bjh0PVYSVVFxzINqPF
github.com/grafana/tail v0.0.0-20230510142333-77b18831edf0/go.mod h1:7t5XR+2IA8P2qggOAHTj/GCZfoLBle3OvNSYh1VkRBU=
github.com/grafana/vmware_exporter v0.0.5-beta h1:2JCqzIWJzns8FN78wPsueC9rT3e3kZo2OUoL5kGMjdM=
github.com/grafana/vmware_exporter v0.0.5-beta/go.mod h1:1CecUZII0zVsVcHtNfNeTTcxK7EksqAsAn/TCCB0Mh4=
github.com/grafana/walqueue v0.0.0-20241118151117-77b057cbe5a2 h1:FJuWxAbqu6uH6t7ymIoVEmO8Gw08x8snEWC42U0Ad4Q=
github.com/grafana/walqueue v0.0.0-20241118151117-77b057cbe5a2/go.mod h1:2B+4gxoOgzgRhstKcikROUHusMXLqd5nE/UKukaQrJI=
github.com/grafana/walqueue v0.0.0-20241202135041-6ec70efeec94 h1:d3Hgun3ailVbNArBIhvRIjmCBOOCO9ClKNpzqQFsMLE=
github.com/grafana/walqueue v0.0.0-20241202135041-6ec70efeec94/go.mod h1:2B+4gxoOgzgRhstKcikROUHusMXLqd5nE/UKukaQrJI=
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
github.com/grobie/gomemcache v0.0.0-20230213081705-239240bbc445 h1:FlKQKUYPZ5yDCN248M3R7x8yu2E3yEZ0H7aLomE4EoE=
github.com/grobie/gomemcache v0.0.0-20230213081705-239240bbc445/go.mod h1:L69/dBlPQlWkcnU76WgcppK5e4rrxzQdi6LhLnK/ytA=
Expand Down Expand Up @@ -3380,6 +3374,8 @@ go.opentelemetry.io/collector/filter v0.112.0 h1:xX0MIfXOkbcWzCcmNqvtpnBDnSZAJmN
go.opentelemetry.io/collector/filter v0.112.0/go.mod h1:ZcPbD9CLxqcQJ5D2dV2Ma0Hm2IKMOYggTLW8dDdZQSQ=
go.opentelemetry.io/collector/internal/memorylimiter v0.112.0 h1:u1hUa48x1qEONUSOtz8dx/c8oz74RpIHyWnGFJ7t0CE=
go.opentelemetry.io/collector/internal/memorylimiter v0.112.0/go.mod h1:BtHruDt40QTW8klZVQCqsVfhVsOkh6hDg5w1cPvLpeU=
go.opentelemetry.io/collector/otelcol v0.112.0 h1:xOq7z5WK5jS1Qg5w+l99H1EiQRq9rHHDv7EIiLryldw=
go.opentelemetry.io/collector/otelcol v0.112.0/go.mod h1:H/HurP0qCcwcWdDRgvTJ/FRrVLnt++agxzHvgLQn/Ew=
go.opentelemetry.io/collector/otelcol/otelcoltest v0.112.0 h1:AdjoVnYl7RxoOvhWZcJb0SWY1VvlRT1cdlCwHBpn9vs=
go.opentelemetry.io/collector/otelcol/otelcoltest v0.112.0/go.mod h1:VSbEYgmiSM5K6p501XD35QuhxbDpkxrfS2Wf5OKnHPs=
go.opentelemetry.io/collector/pdata v1.18.0 h1:/yg2rO2dxqDM2p6GutsMCxXN6sKlXwyIz/ZYyUPONBg=
Expand All @@ -3394,6 +3390,8 @@ go.opentelemetry.io/collector/pipeline/pipelineprofiles v0.112.0 h1:opXGNrlJAjYR
go.opentelemetry.io/collector/pipeline/pipelineprofiles v0.112.0/go.mod h1:c9yn4x+vY3G10eLCRuUu/oH7Y8YdE/BsgmLWmfHkaNY=
go.opentelemetry.io/collector/processor v0.112.0 h1:nMv9DOBYR9MB78ddUgY3A3ytwAwk3t4HQMNIu+w8o0g=
go.opentelemetry.io/collector/processor v0.112.0/go.mod h1:AJ8EHq8Z/ev90f4gU6G5ULUncdpWmBRATYk8ioR3pvw=
go.opentelemetry.io/collector/processor/batchprocessor v0.112.0 h1:Dq/RpdClawI8HrnSi177LziPjfHo733BWOCgRTbWrfY=
go.opentelemetry.io/collector/processor/batchprocessor v0.112.0/go.mod h1:QLQ31rGjPuMc/nGw4rL4HzQI9F0jVAPEmC342chxoqA=
go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.112.0 h1:+V+4OUcg1s3CrZpttT4dA+Uuv7VWpOIPQpOkcsrMBIo=
go.opentelemetry.io/collector/processor/memorylimiterprocessor v0.112.0/go.mod h1:f/eEZ3JMbRNLsRzNwATtTjuulDrLvhYMvXinLrmHtTU=
go.opentelemetry.io/collector/processor/processorprofiles v0.112.0 h1:Aef68SAbmBbhbsZZPuZb0ECwkV05vIcHIizGOGbWsbM=
Expand All @@ -3408,6 +3406,8 @@ go.opentelemetry.io/collector/receiver/receiverprofiles v0.112.0 h1:SShkZsWRsFss
go.opentelemetry.io/collector/receiver/receiverprofiles v0.112.0/go.mod h1:615smszDXiz4YWwXslxlAjX7FzOVDU7Bk6xARFk+zpk=
go.opentelemetry.io/collector/semconv v0.112.0 h1:JPQyvZhlNLVSuVI+FScONaiFygB7h7NTZceUEKIQUEc=
go.opentelemetry.io/collector/semconv v0.112.0/go.mod h1:zCJ5njhWpejR+A40kiEoeFm1xq1uzyZwMnRNX6/D82A=
go.opentelemetry.io/collector/service v0.112.0 h1:SI5bwPrRHLRn/kR9AoSSDX/8vaKFe+NMYloAcXfWMSE=
go.opentelemetry.io/collector/service v0.112.0/go.mod h1:VTLnax+DjHal3q7WKQO0ITjWdfPTq2txaoNRcVXYzgE=
go.opentelemetry.io/contrib/config v0.10.0 h1:2JknAzMaYjxrHkTnZh3eOme/Y2P5eHE2SWfhfV6Xd6c=
go.opentelemetry.io/contrib/config v0.10.0/go.mod h1:aND2M6/KfNkntI5cyvHriR/zvZgPf8j9yETdSmvpfmc=
go.opentelemetry.io/contrib/detectors/aws/ec2 v1.28.0 h1:d+y/wygENfwEbVpo7c3A9GfnMhoTiepQcthQSh+Mc9g=
Expand Down
19 changes: 18 additions & 1 deletion internal/component/loki/source/podlogs/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package podlogs
import (
"context"
"fmt"
"slices"
"sort"
"strings"
"sync"
Expand All @@ -15,6 +16,7 @@ import (
"github.com/grafana/alloy/internal/service/cluster"
"github.com/grafana/ckit/shard"
"github.com/prometheus/common/model"
prom_lbls "github.com/prometheus/prometheus/model/labels"
promlabels "github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/model/relabel"
"github.com/prometheus/prometheus/util/strutil"
Expand Down Expand Up @@ -126,6 +128,17 @@ func (r *reconciler) Reconcile(ctx context.Context, cli client.Client) error {
return nil
}

func filterLabels(lbls prom_lbls.Labels, keysToKeep []string) prom_lbls.Labels {
var res prom_lbls.Labels
for _, k := range lbls {
if slices.Contains(keysToKeep, k.Name) {
res = append(res, prom_lbls.Label{Name: k.Name, Value: k.Value})
}
}
sort.Sort(res)
return res
}

func distributeTargets(c cluster.Cluster, targets []*kubetail.Target) []*kubetail.Target {
if c == nil {
return targets
Expand All @@ -140,7 +153,11 @@ func distributeTargets(c cluster.Cluster, targets []*kubetail.Target) []*kubetai
res := make([]*kubetail.Target, 0, resCap)

for _, target := range targets {
peers, err := c.Lookup(shard.StringKey(target.Labels().String()), 1, shard.OpReadWrite)
// Only take into account the labels necessary to uniquely identify a pod/container instance.
// If we take into account more labels than necessary, there may be issues due to labels changing
// over the lifetime of the pod.
clusteringLabels := filterLabels(target.DiscoveryLabels(), kubetail.ClusteringLabels)
peers, err := c.Lookup(shard.StringKey(clusteringLabels.String()), 1, shard.OpReadWrite)
if err != nil {
// This can only fail in case we ask for more owners than the
// available peers. This will never happen, but in any case we fall
Expand Down
18 changes: 18 additions & 0 deletions internal/component/prometheus/write/queue/e2e_stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const alloyMetadataRetried = "alloy_queue_metadata_network_retried"

const alloyNetworkTimestamp = "alloy_queue_series_network_timestamp_seconds"

const alloyDrift = "alloy_queue_series_timestamp_drift_seconds"

// TestMetadata is the large end to end testing for the queue based wal, specifically for metadata.
func TestMetadata(t *testing.T) {
// Check assumes you are checking for any value that is not 0.
Expand Down Expand Up @@ -228,6 +230,10 @@ func TestMetrics(t *testing.T) {
name: inTimestamp,
valueFunc: isReasonableTimeStamp,
},
{
name: alloyDrift,
valueFunc: greaterThenZero,
},
},
},
{
Expand Down Expand Up @@ -270,6 +276,10 @@ func TestMetrics(t *testing.T) {
name: inTimestamp,
valueFunc: isReasonableTimeStamp,
},
{
name: alloyDrift,
valueFunc: greaterThenZero,
},
},
},
// histograms
Expand Down Expand Up @@ -353,6 +363,10 @@ func TestMetrics(t *testing.T) {
name: inTimestamp,
valueFunc: isReasonableTimeStamp,
},
{
name: alloyDrift,
valueFunc: greaterThenZero,
},
},
},
{
Expand Down Expand Up @@ -395,6 +409,10 @@ func TestMetrics(t *testing.T) {
name: inTimestamp,
valueFunc: isReasonableTimeStamp,
},
{
name: alloyDrift,
valueFunc: greaterThenZero,
},
},
},
// TURNING OFF EXEMPLAR TESTS until underlying issue is resolved.
Expand Down
8 changes: 4 additions & 4 deletions internal/component/prometheus/write/queue/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func handlePost(t *testing.T, _ http.ResponseWriter, r *http.Request) ([]prompb.
}

func makeSeries(index int) (int64, float64, labels.Labels) {
return time.Now().UTC().Unix(), float64(index), labels.FromStrings(fmt.Sprintf("name_%d", index), fmt.Sprintf("value_%d", index))
return time.Now().UTC().UnixMilli(), float64(index), labels.FromStrings(fmt.Sprintf("name_%d", index), fmt.Sprintf("value_%d", index))
}

func makeMetadata(index int) (metadata.Metadata, labels.Labels) {
Expand All @@ -246,13 +246,13 @@ func makeMetadata(index int) (metadata.Metadata, labels.Labels) {
}

func makeHistogram(index int) (int64, labels.Labels, *histogram.Histogram) {
return time.Now().UTC().Unix(), labels.FromStrings(fmt.Sprintf("name_%d", index), fmt.Sprintf("value_%d", index)), hist(index)
return time.Now().UTC().UnixMilli(), labels.FromStrings(fmt.Sprintf("name_%d", index), fmt.Sprintf("value_%d", index)), hist(index)
}

func makeExemplar(index int) exemplar.Exemplar {
return exemplar.Exemplar{
Labels: labels.FromStrings(fmt.Sprintf("name_%d", index), fmt.Sprintf("value_%d", index)),
Ts: time.Now().Unix(),
Ts: time.Now().UnixMilli(),
HasTs: true,
Value: float64(index),
}
Expand Down Expand Up @@ -305,7 +305,7 @@ func histSpanSame(t *testing.T, h []histogram.Span, pb []prompb.BucketSpan) {
}

func makeFloatHistogram(index int) (int64, labels.Labels, *histogram.FloatHistogram) {
return time.Now().UTC().Unix(), labels.FromStrings(fmt.Sprintf("name_%d", index), fmt.Sprintf("value_%d", index)), histFloat(index)
return time.Now().UTC().UnixMilli(), labels.FromStrings(fmt.Sprintf("name_%d", index), fmt.Sprintf("value_%d", index)), histFloat(index)
}

func histFloat(i int) *histogram.FloatHistogram {
Expand Down
2 changes: 1 addition & 1 deletion internal/component/pyroscope/write/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func validateAppName(n string) error {
}

func isAppNameRuneAllowed(r rune) bool {
return r == '-' || r == '.' || isTagKeyRuneAllowed(r)
return r == '-' || r == '.' || r == '/' || isTagKeyRuneAllowed(r)
}

func isTagKeyReserved(k string) bool {
Expand Down
Loading

0 comments on commit c10d025

Please sign in to comment.