Skip to content

Commit

Permalink
main merge
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdurham committed Sep 23, 2024
2 parents 371443a + 670c894 commit 7c96b7c
Show file tree
Hide file tree
Showing 10 changed files with 445 additions and 145 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-linux-build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
check-linux-build-image:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
# platform, but we're really only looking for issues that are
# architecture-independent.
linux:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build image
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
name: Build
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-latest"
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
20 changes: 15 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,31 @@ internal API changes are not present.
Main (unreleased)
-----------------

### Features

- Add the function `path_join` to the stdlib. (@wildum)

### Bugfixes

- Update yet-another-cloudwatch-exporter from v0.60.0 vo v0.61.0: (@morreymeyer)
- Update yet-another-cloudwatch-exporter from v0.60.0 vo v0.61.0: (@morremeyer)
- Fixes a bug where cloudwatch S3 metrics are reported as `0`

- Fixed incorrect debug metric names in `otelcol.exporter.awss3`, `otelcol.exporter.otlp`, `otelcol.processor.batch`, `otelcol.processor.deltatocumulative` and `otelcol.processor.otlp`
which have changed due to an upstream breaking change. The dashboards and alerts in the mixin have also been fixed. (@thampiotr)

- Fix issue where `loki.source.kubernetes` took into account all labels, instead of specific logs labels. Resulting in duplication. (@mattdurham)

v1.4.0-rc.2
### Other changes

- Small fix in UI stylesheet to fit more content into visible table area. (@defanator)

- Changed OTEL alerts in Alloy mixin to use success rate for tracing. (@thampiotr)

v1.4.0-rc.3
-----------------

### Breaking changes

- Some debug metrics for `otelcol` components have changed. (@thampiotr)
For example, `otelcol.exporter.otlp`'s `exporter_sent_spans_ratio_total` metric is now `otelcol_exporter_sent_spans_total`.

- [otelcol.processor.transform] The functions `convert_sum_to_gauge` and `convert_gauge_to_sum` must now be used in the `metric` `context` rather than in the `datapoint` context.
https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/34567 (@wildum)

Expand Down
24 changes: 24 additions & 0 deletions docs/sources/reference/stdlib/file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
canonical: https://grafana.com/docs/alloy/latest/reference/stdlib/file/
description: Learn about file functions
menuTitle: file
title: file
---

# file

The `file` namespace contains functions related to files.

## file.path_join

The `file.path_join` function joins any number of path elements into a single path, separating them with an OS-specific separator.

### Examples

```
> file.path_join()
""
> file.path_join("this/is", "a/path")
"this/is/a/path"
```
3 changes: 1 addition & 2 deletions internal/web/ui/src/features/component/Table.module.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.table {
border-collapse: collapse;
width: 100%;
table-layout: fixed;
}

.table td,
Expand Down Expand Up @@ -49,4 +48,4 @@
content: "▲";
float: right;
}
}
}
472 changes: 353 additions & 119 deletions internal/web/ui/yarn.lock

Large diffs are not rendered by default.

35 changes: 19 additions & 16 deletions operations/alloy-mixin/alerts/opentelemetry.libsonnet
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
local alert = import './utils/alert.jsonnet';

{
local successRateQuery(enableK8sCluster, failed, success) =
local sumBy = if enableK8sCluster then "cluster, namespace, job" else "job";
|||
(1 - sum by (%s) (
rate(%s{}[1m])
/
(rate(%s{}[1m]) + rate(%s{}[1m]))
)
) < 0.95
||| % [sumBy, failed, failed, success],

newOpenTelemetryAlertsGroup(enableK8sCluster=true):
alert.newGroup(
'alloy_otelcol',
[
// An otelcol.exporter component rcould not push some spans to the pipeline.
// An otelcol.receiver component could not push over 5% of spans to the pipeline.
// This could be due to reaching a limit such as the ones
// imposed by otelcol.processor.memory_limiter.
alert.newRule(
'OtelcolReceiverRefusedSpans',
if enableK8sCluster then
'sum by (cluster, namespace, job) (rate(otelcol_receiver_refused_spans_total{}[1m])) > 0'
else
'sum by (job) (rate(otelcol_receiver_refused_spans_total{}[1m])) > 0'
,
'The receiver could not push some spans to the pipeline.',
successRateQuery(enableK8sCluster, "otelcol_receiver_refused_spans_total", "otelcol_receiver_accepted_spans_total"),
'The receiver pushing spans to the pipeline success rate is below 95%.',
'The receiver could not push some spans to the pipeline under job {{ $labels.job }}. This could be due to reaching a limit such as the ones imposed by otelcol.processor.memory_limiter.',
'5m',
'10m',
),

// The exporter failed to send spans to their destination.
// The exporter success rate is below 95%.
// There could be an issue with the payload or with the destination endpoint.
alert.newRule(
'OtelcolExporterFailedSpans',
if enableK8sCluster then
'sum by (cluster, namespace, job) (rate(otelcol_exporter_send_failed_spans_total{}[1m])) > 0'
else
'sum by (job) (rate(otelcol_exporter_send_failed_spans_total{}[1m])) > 0'
,
'The exporter failed to send spans to their destination.',
successRateQuery(enableK8sCluster, "otelcol_exporter_send_failed_spans_total", "otelcol_exporter_sent_spans_total"),
'The exporter sending spans success rate is below 95%.',
'The exporter failed to send spans to their destination under job {{ $labels.job }}. There could be an issue with the payload or with the destination endpoint.',
'5m',
'10m',
),
]
)
Expand Down
6 changes: 6 additions & 0 deletions syntax/internal/stdlib/stdlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"maps"
"os"
"path/filepath"
"strings"

"github.com/grafana/alloy/syntax/alloytypes"
Expand Down Expand Up @@ -53,13 +54,18 @@ var Identifiers = map[string]interface{}{
"array": array,
"encoding": encoding,
"string": str,
"file": file,
}

func init() {
// Adds the deprecatedIdentifiers to the map of valid identifiers.
maps.Copy(Identifiers, DeprecatedIdentifiers)
}

var file = map[string]interface{}{
"path_join": filepath.Join,
}

var encoding = map[string]interface{}{
"from_json": jsonDecode,
"from_yaml": yamlDecode,
Expand Down
24 changes: 24 additions & 0 deletions syntax/vm/vm_stdlib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,30 @@ func TestStdlib_StringFunc(t *testing.T) {
}
}

func TestStdlibFileFunc(t *testing.T) {
tt := []struct {
name string
input string
expect interface{}
}{
{"file.path_join", `file.path_join("this/is", "a/path")`, "this/is/a/path"},
{"file.path_join empty", `file.path_join()`, ""},
}

for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
expr, err := parser.ParseExpression(tc.input)
require.NoError(t, err)

eval := vm.New(expr)

rv := reflect.New(reflect.TypeOf(tc.expect))
require.NoError(t, eval.Evaluate(nil, rv.Interface()))
require.Equal(t, tc.expect, rv.Elem().Interface())
})
}
}

func BenchmarkConcat(b *testing.B) {
// There's a bit of setup work to do here: we want to create a scope holding
// a slice of the Person type, which has a fair amount of data in it.
Expand Down

0 comments on commit 7c96b7c

Please sign in to comment.