Skip to content

Commit

Permalink
Merge branch 'main' into docs/update-topics-concepts
Browse files Browse the repository at this point in the history
  • Loading branch information
clayton-cornell authored Dec 11, 2023
2 parents 7153332 + a2badce commit 49b26e4
Show file tree
Hide file tree
Showing 37 changed files with 909 additions and 182 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/helm-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
path: source

- name: Install chart-testing
uses: helm/[email protected].0
uses: helm/[email protected].1

- name: List changed charts
id: list-changed
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/helm-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
check-latest: true

- name: Install chart-testing
uses: helm/[email protected].0
uses: helm/[email protected].1

- name: Determine changed charts
id: list-changed
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,33 @@ Main (unreleased)

- `pyroscope.ebpf` support python on arm64 platforms. (@korniltsev)

- `mimir.rules.kubernetes` may now retry its startup on failure. (@hainenber)

- Added links between compatible components in the documentation to make it
easier to discover them. (@thampiotr)

- Allow defining `HTTPClientConfig` for `discovery.ec2`. (@cmbrad)

- The `remote.http` component can optionally define a request body. (@tpaschalis)

### Bugfixes

- Update `pyroscope.ebpf` to fix a logical bug causing to profile to many kthreads instead of regular processes https://github.com/grafana/pyroscope/pull/2778 (@korniltsev)

- Update `pyroscope.ebpf` to produce more optimal pprof profiles for python processes https://github.com/grafana/pyroscope/pull/2788 (@korniltsev)

- In Static mode's `traces` subsystem, `spanmetrics` used to be generated prior to load balancing.
This could lead to inaccurate metrics. This issue only affects Agents using both `spanmetrics` and
`load_balancing`, when running in a load balanced cluster with more than one Agent instance. (@ptodev)

- Fixes `loki.source.docker` a behavior that synced an incomplete list of targets to the tailer manager. (@FerdinandvHagen)

- Fixes `otelcol.connector.servicegraph` store ttl default value from 2ms to 2s. (@rlankfo)

### Other changes

- Bump github.com/IBM/sarama from v1.41.2 to v1.42.1

v0.38.1 (2023-11-30)
--------------------

Expand Down
3 changes: 1 addition & 2 deletions cmd/grafana-agent-operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
RELEASE_BUILD=${RELEASE_BUILD} VERSION=${VERSION} \
make operator

FROM ubuntu:lunar
FROM ubuntu:mantic

LABEL org.opencontainers.image.source="https://github.com/grafana/agent"

# Install dependencies needed at runtime.
RUN <<EOF
apt-get update
apt-get install -qy libsystemd-dev tzdata ca-certificates
apt-get upgrade -y
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
EOF

Expand Down
3 changes: 1 addition & 2 deletions cmd/grafana-agent/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
GOEXPERIMENT=${GOEXPERIMENT} \
make agent

FROM ubuntu:lunar
FROM ubuntu:mantic

LABEL org.opencontainers.image.source="https://github.com/grafana/agent"

# Install dependencies needed at runtime.
RUN <<EOF
apt-get update
apt-get install -qy libsystemd-dev tzdata ca-certificates
apt-get upgrade -y
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
EOF

Expand Down
3 changes: 1 addition & 2 deletions cmd/grafana-agentctl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,14 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
GO_TAGS="netgo promtail_journal_enabled" \
make agentctl

FROM ubuntu:lunar
FROM ubuntu:mantic

LABEL org.opencontainers.image.source="https://github.com/grafana/agent"

# Install dependencies needed at runtime.
RUN <<EOF
apt-get update
apt-get install -qy libsystemd-dev tzdata ca-certificates
apt-get upgrade -y
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
EOF

Expand Down
20 changes: 12 additions & 8 deletions component/discovery/aws/ec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/aws/aws-sdk-go/aws/ec2metadata"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/grafana/agent/component"
"github.com/grafana/agent/component/common/config"
"github.com/grafana/agent/component/discovery"
"github.com/grafana/river/rivertypes"
promcfg "github.com/prometheus/common/config"
Expand Down Expand Up @@ -42,18 +43,21 @@ type EC2Arguments struct {
RefreshInterval time.Duration `river:"refresh_interval,attr,optional"`
Port int `river:"port,attr,optional"`
Filters []*EC2Filter `river:"filter,block,optional"`

HTTPClientConfig config.HTTPClientConfig `river:",squash"`
}

func (args EC2Arguments) Convert() *promaws.EC2SDConfig {
cfg := &promaws.EC2SDConfig{
Endpoint: args.Endpoint,
Region: args.Region,
AccessKey: args.AccessKey,
SecretKey: promcfg.Secret(args.SecretKey),
Profile: args.Profile,
RoleARN: args.RoleARN,
RefreshInterval: model.Duration(args.RefreshInterval),
Port: args.Port,
Endpoint: args.Endpoint,
Region: args.Region,
AccessKey: args.AccessKey,
SecretKey: promcfg.Secret(args.SecretKey),
Profile: args.Profile,
RoleARN: args.RoleARN,
RefreshInterval: model.Duration(args.RefreshInterval),
Port: args.Port,
HTTPClientConfig: *args.HTTPClientConfig.Convert(),
}
for _, f := range args.Filters {
cfg.Filters = append(cfg.Filters, &promaws.EC2Filter{
Expand Down
29 changes: 29 additions & 0 deletions component/discovery/aws/ec2_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package aws

import (
"net/url"
"testing"

"github.com/grafana/agent/component/common/config"
"github.com/stretchr/testify/require"
"gotest.tools/assert"
)

func TestConvert(t *testing.T) {
// parse example proxy
u, err := url.Parse("http://example:8080")
require.NoError(t, err)
httpClientConfig := config.DefaultHTTPClientConfig
httpClientConfig.ProxyURL = config.URL{URL: u}

// example configuration
riverArgs := EC2Arguments{
Region: "us-east-1",
HTTPClientConfig: httpClientConfig,
}

// ensure values are set
promArgs := riverArgs.Convert()
assert.Equal(t, "us-east-1", promArgs.Region)
assert.Equal(t, "http://example:8080", promArgs.HTTPClientConfig.ProxyURL.String())
}
2 changes: 1 addition & 1 deletion component/faro/receiver/sourcemaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/go-sourcemap/sourcemap"
"github.com/grafana/agent/component/faro/receiver/internal/payload"
"github.com/grafana/agent/pkg/flow/logging/level"
"github.com/minio/pkg/wildcard"
"github.com/grafana/agent/pkg/util/wildcard"
"github.com/prometheus/client_golang/prometheus"
"github.com/vincent-petithory/dataurl"
)
Expand Down
6 changes: 3 additions & 3 deletions component/loki/source/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ func (c *Component) Update(args component.Arguments) error {
return err
}
targets = append(targets, tgt)

// This will never fail because it only fails if the context gets canceled.
_ = c.manager.syncTargets(context.Background(), targets)
}

// This will never fail because it only fails if the context gets canceled.
_ = c.manager.syncTargets(context.Background(), targets)

c.args = newArgs
return nil
}
Expand Down
4 changes: 3 additions & 1 deletion component/loki/source/windowsevent/bookmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ package windowsevent
import (
"bytes"
"errors"
"github.com/natefinch/atomic"
"io"
"io/fs"
"os"

"github.com/natefinch/atomic"

"github.com/grafana/loki/clients/pkg/promtail/targets/windows/win_eventlog"
)

Expand Down Expand Up @@ -55,6 +56,7 @@ func newBookMark(path string) (*bookMark, error) {
if err != nil {
return nil, err
}
defer file.Close()
fileContent, err := io.ReadAll(file)
if err != nil {
return nil, err
Expand Down
24 changes: 18 additions & 6 deletions component/mimir/rules/kubernetes/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/grafana/agent/component"
"github.com/grafana/agent/pkg/flow/logging/level"
mimirClient "github.com/grafana/agent/pkg/mimir/client"
"github.com/grafana/dskit/backoff"
"github.com/grafana/dskit/instrument"
promListers "github.com/prometheus-operator/prometheus-operator/pkg/client/listers/monitoring/v1"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -153,10 +154,22 @@ func New(o component.Options, args Arguments) (*Component, error) {
}

func (c *Component) Run(ctx context.Context) error {
err := c.startup(ctx)
if err != nil {
level.Error(c.log).Log("msg", "starting up component failed", "err", err)
c.reportUnhealthy(err)
startupBackoff := backoff.New(
ctx,
backoff.Config{
MinBackoff: 1 * time.Second,
MaxBackoff: 10 * time.Second,
MaxRetries: 0, // infinite retries
},
)
for {
if err := c.startup(ctx); err != nil {
level.Error(c.log).Log("msg", "starting up component failed", "err", err)
c.reportUnhealthy(err)
} else {
break
}
startupBackoff.Wait()
}

for {
Expand Down Expand Up @@ -205,8 +218,7 @@ func (c *Component) startup(ctx context.Context) error {
if err := c.startRuleInformer(); err != nil {
return err
}
err := c.syncMimir(ctx)
if err != nil {
if err := c.syncMimir(ctx); err != nil {
return err
}
go c.eventLoop(ctx)
Expand Down
2 changes: 1 addition & 1 deletion component/otelcol/connector/servicegraph/servicegraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ var DefaultArguments = Arguments{
Dimensions: []string{},
Store: StoreConfig{
MaxItems: 1000,
TTL: 2 * time.Millisecond,
TTL: 2 * time.Second,
},
CacheLoop: 1 * time.Minute,
StoreExpirationLoop: 2 * time.Second,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestArguments_UnmarshalRiver(t *testing.T) {
Dimensions: []string{},
Store: servicegraphprocessor.StoreConfig{
MaxItems: 1000,
TTL: 2 * time.Millisecond,
TTL: 2 * time.Second,
},
CacheLoop: 1 * time.Minute,
StoreExpirationLoop: 2 * time.Second,
Expand Down
8 changes: 7 additions & 1 deletion component/remote/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Arguments struct {

Method string `river:"method,attr,optional"`
Headers map[string]string `river:"headers,attr,optional"`
Body string `river:"body,attr,optional"`

Client common_config.HTTPClientConfig `river:"client,block,optional"`
}
Expand Down Expand Up @@ -193,7 +194,12 @@ func (c *Component) pollError() error {
ctx, cancel := context.WithTimeout(context.Background(), c.args.PollTimeout)
defer cancel()

req, err := http.NewRequest(c.args.Method, c.args.URL, nil)
var body io.Reader
if c.args.Body != "" {
body = strings.NewReader(c.args.Body)
}

req, err := http.NewRequest(c.args.Method, c.args.URL, body)
if err != nil {
level.Error(c.log).Log("msg", "failed to build request", "err", err)
return fmt.Errorf("building request: %w", err)
Expand Down
7 changes: 6 additions & 1 deletion component/remote/http/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package http_test
import (
"context"
"fmt"
"io"
"net/http"
"net/http/httptest"
"sync"
Expand All @@ -27,6 +28,9 @@ func Test(t *testing.T) {
defer srv.Close()

handler.SetHandler(func(w http.ResponseWriter, r *http.Request) {
b, err := io.ReadAll(r.Body)
require.NoError(t, err)
require.Equal(t, string(b), "hello there!")
fmt.Fprintln(w, "Hello, world!")
})

Expand All @@ -40,10 +44,11 @@ func Test(t *testing.T) {
"x-custom" = "value",
"User-Agent" = "custom_useragent",
}
body = "%s"
poll_frequency = "50ms"
poll_timeout = "25ms"
`, srv.URL, http.MethodPut)
`, srv.URL, http.MethodPut, "hello there!")
var args http_component.Arguments
require.NoError(t, river.Unmarshal([]byte(cfg), &args))

Expand Down
2 changes: 2 additions & 0 deletions docs/docs_updated_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !windows

package docs

import (
Expand Down
39 changes: 15 additions & 24 deletions docs/sources/flow/monitoring/component_metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,21 @@ weight: 200

# Component metrics

{{< param "PRODUCT_NAME" >}} [components][] may optionally expose Prometheus metrics
which can be used to investigate the behavior of that component. These
component-specific metrics are only generated when an instance of that
component is running.

> Component-specific metrics are different than any metrics being processed by
> the component. Component-specific metrics are used to expose the state of a
> component for observability, alerting, and debugging.
Component-specific metrics are exposed at the `/metrics` HTTP endpoint of the
{{< param "PRODUCT_NAME" >}} HTTP server, which defaults to listening on
`http://localhost:12345`.

> The documentation for the [`grafana-agent run`][grafana-agent run] command describes how to
> modify the address {{< param "PRODUCT_NAME" >}} listens on for HTTP traffic.
Component-specific metrics will have a `component_id` label matching the
component ID generating those metrics. For example, component-specific metrics
for a `prometheus.remote_write` component labeled `production` will have a
`component_id` label with the value `prometheus.remote_write.production`.

The [reference documentation][] for each component will describe the list of
component-specific metrics that component exposes. Not all components will
expose metrics.
{{< param "PRODUCT_NAME" >}} [components][] may optionally expose Prometheus metrics which can be used to investigate the behavior of that component.
These component-specific metrics are only generated when an instance of that component is running.

> Component-specific metrics are different than any metrics being processed by the component.
> Component-specific metrics are used to expose the state of a component for observability, alerting, and debugging.
Component-specific metrics are exposed at the `/metrics` HTTP endpoint of the {{< param "PRODUCT_NAME" >}} HTTP server, which defaults to listening on `http://localhost:12345`.

> The documentation for the [`grafana-agent run`][grafana-agent run] command describes how to > modify the address {{< param "PRODUCT_NAME" >}} listens on for HTTP traffic.
Component-specific metrics have a `component_id` label matching the component ID generating those metrics.
For example, component-specific metrics for a `prometheus.remote_write` component labeled `production` will have a `component_id` label with the value `prometheus.remote_write.production`.

The [reference documentation][] for each component described the list of component-specific metrics that the component exposes.
Not all components expose metrics.

{{% docs/reference %}}
[components]: "/docs/agent/ -> /docs/agent/<AGENT_VERSION>/flow/concepts/components.md"
Expand Down
Loading

0 comments on commit 49b26e4

Please sign in to comment.