Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tempo] Automatic Logging #551

Merged
merged 34 commits into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9cfe6d9
garbage POC, let's goooooooooooOOO!
joe-elliott Apr 13, 2021
aed6b14
Added basic configuration
joe-elliott Apr 14, 2021
09d2464
Added skeleton processor
joe-elliott Apr 14, 2021
6ee0a46
first pass config wiring
joe-elliott Apr 14, 2021
d161788
got things to work?
joe-elliott Apr 14, 2021
71482e5
kinda sorta works
joe-elliott Apr 14, 2021
ebc8aa7
made things work
joe-elliott Apr 14, 2021
1c88fdc
fixed-ish dur. upped loki and grafana
joe-elliott Apr 14, 2021
4dc4805
fixed duration, added svc name, did processes correctly
joe-elliott Apr 14, 2021
0082076
Added tempo
joe-elliott Apr 15, 2021
3ad6059
configurable tags
joe-elliott Apr 20, 2021
bdda148
config
joe-elliott Apr 20, 2021
74b72a2
Addd stopping flag
joe-elliott Apr 20, 2021
f6463d9
Added tests
joe-elliott Apr 20, 2021
7d3dc64
Added configurable stuff
joe-elliott Apr 20, 2021
c974804
Added automatic logging to docs
joe-elliott Apr 20, 2021
e0238ea
added otel config test
joe-elliott Apr 20, 2021
7e018c3
Made tid configurable
joe-elliott Apr 20, 2021
e967715
changelog
joe-elliott Apr 20, 2021
df7002e
Merge branch 'main' into loki-exporter
joe-elliott Apr 20, 2021
2395de8
Removed zero valued defaults
joe-elliott Apr 21, 2021
55d8f4e
Put changelog entry in the proper spot
joe-elliott Apr 21, 2021
c210739
- _processor
joe-elliott Apr 21, 2021
7b6761c
fixed tests
joe-elliott Apr 21, 2021
a8338d5
Added cross config validation
joe-elliott Apr 21, 2021
0370820
review suggestions
joe-elliott Apr 21, 2021
71c8fd5
First pass SendEntry
joe-elliott Apr 21, 2021
a0d6503
lint
joe-elliott Apr 21, 2021
f345a73
Added configurable timeout
joe-elliott Apr 21, 2021
dbcefc8
Addd logging message when bad things happen
joe-elliott Apr 21, 2021
93c3033
Actually check sent :P
joe-elliott Apr 21, 2021
c70d070
review cleanup
joe-elliott Apr 22, 2021
8633639
config updates
joe-elliott Apr 22, 2021
a05e17c
duh
joe-elliott Apr 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ func (c *Config) ApplyDefaults() error {
c.Integrations.PrometheusRemoteWrite = c.Prometheus.Global.RemoteWrite
}

// since the Tempo config might rely on an existing Loki config
// this check is made here to look for cross config issues before we attempt to load
if err := c.Tempo.Validate(c.Loki); err != nil {
return err
}

return nil
}

Expand Down
47 changes: 47 additions & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,50 @@ func TestConfig_Defaults(t *testing.T) {
require.Equal(t, prom.DefaultConfig, c.Prometheus)
require.Equal(t, integrations.DefaultManagerConfig, c.Integrations)
}

func TestConfig_TempoLokiValidation(t *testing.T) {
// test failure
cfg := `
loki:
configs:
- name: foo
positions:
filename: /tmp/positions.yaml
clients:
- url: http://loki:3100/loki/api/v1/push
tempo:
configs:
- name: default
automatic_logging:
loki_name: default
spans: true
`

fs := flag.NewFlagSet("test", flag.ExitOnError)
_, err := load(fs, []string{"-config.file", "test"}, func(_ string, _ bool, c *Config) error {
return LoadBytes([]byte(cfg), false, c)
})
require.EqualError(t, err, "error in config file: specified loki config default not found")

// test success
cfg = `
loki:
configs:
- name: foo
positions:
filename: /tmp/positions.yaml
clients:
- url: http://loki:3100/loki/api/v1/push
tempo:
configs:
- name: default
automatic_logging:
loki_name: foo
spans: true`

fs = flag.NewFlagSet("test", flag.ExitOnError)
_, err = load(fs, []string{"-config.file", "test"}, func(_ string, _ bool, c *Config) error {
return LoadBytes([]byte(cfg), false, c)
})
require.NoError(t, err)
}
24 changes: 22 additions & 2 deletions pkg/tempo/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net"
"time"

"github.com/grafana/agent/pkg/loki"
"github.com/grafana/agent/pkg/tempo/automaticloggingprocessor"
"github.com/grafana/agent/pkg/tempo/noopreceiver"
"github.com/grafana/agent/pkg/tempo/promsdprocessor"
Expand Down Expand Up @@ -61,11 +62,11 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
if err := unmarshal((*plain)(c)); err != nil {
return err
}
return c.Validate()
return nil
joe-elliott marked this conversation as resolved.
Show resolved Hide resolved
}

// Validate ensures that the Config is valid.
func (c *Config) Validate() error {
func (c *Config) Validate(lokiConfig loki.Config) error {
joe-elliott marked this conversation as resolved.
Show resolved Hide resolved
names := make(map[string]struct{}, len(c.Configs))
for idx, c := range c.Configs {
if c.Name == "" {
Expand All @@ -77,6 +78,25 @@ func (c *Config) Validate() error {
names[c.Name] = struct{}{}
}

// check to make sure that any referenced Loki configs exist
for _, inst := range c.Configs {
if inst.AutomaticLogging != nil {
found := false
lokiName := inst.AutomaticLogging.LokiName

for _, lokiInst := range lokiConfig.Configs {
if lokiInst.Name == lokiName {
found = true
break
}
}

if !found {
return fmt.Errorf("specified loki config %s not found", lokiName)
}
}
}

return nil
}

Expand Down