Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions docs/en/02-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,10 @@ Config for `/errorgroups` API handlers.
+ **`release`** *`[]string`* *`default=[]`*

`log_tags` keys for `release` column.

+ **`env`** *`[]string`* *`default=[]`*

`log_tags` keys for `env` column.

+ **`query_filter`** *`map[string]string`* *`optional`*

Expand Down
4 changes: 4 additions & 0 deletions docs/ru/02-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,10 @@ handlers:
+ **`release`** *`[]string`* *`default=[]`*

Ключи `log_tags` для столбца `release`.

+ **`env`** *`[]string`* *`default=[]`*

Ключи `log_tags` для столбца `env`.

+ **`query_filter`** *`map[string]string`* *`optional`*

Expand Down
1 change: 1 addition & 0 deletions internal/app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ type SeqAPI struct {

type LogTagsMapping struct {
Release []string `yaml:"release"`
Env []string `yaml:"env"`
}

type ErrorGroups struct {
Expand Down
6 changes: 3 additions & 3 deletions internal/pkg/repository_ch/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ func (r *repository) GetErrorReleases(
OrderBy("release")

for col, val := range r.queryFilter {
q = q.Where(sq.Eq{col: val}).GroupBy(col)
q = q.Where(sq.Eq{col: val})
}

if req.Env != nil && *req.Env != "" {
Expand Down Expand Up @@ -410,7 +410,7 @@ func (r *repository) GetServices(
OrderBy("service")

for col, val := range r.queryFilter {
q = q.Where(sq.Eq{col: val}).GroupBy(col)
q = q.Where(sq.Eq{col: val})
}

if req.Env != nil && *req.Env != "" {
Expand All @@ -429,7 +429,7 @@ func (r *repository) GetServices(
rows, err := r.conn.Query(ctx, metricLabels, query, args...)
if err != nil {
incErrorMetric(err, metricLabels)
return nil, fmt.Errorf("failed to get releases: %w", err)
return nil, fmt.Errorf("failed to get services: %w", err)
}

services := make([]string, 0)
Expand Down
13 changes: 9 additions & 4 deletions internal/pkg/service/errorgroups/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,18 @@ func (s *Service) GetDetails(
ByRelease: calcDistribution(counts.ByRelease),
}

// remove tags if they are not included in request
if req.Release == nil || *req.Release == "" {
for _, r := range s.logTagsMapping.Release {
delete(details.LogTags, r)
clearLogTags := func(filter *string, mapping []string) {
if filter == nil || *filter == "" {
for _, v := range mapping {
delete(details.LogTags, v)
}
}
}

// remove tags if they are not included in request
clearLogTags(req.Release, s.logTagsMapping.Release)
clearLogTags(req.Env, s.logTagsMapping.Env)

return details, nil
}

Expand Down