Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

PMM-5680 store agents logs #197

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
13 changes: 11 additions & 2 deletions commands/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,20 @@ func addClientData(ctx context.Context, zipW *zip.Writer) {
logrus.Errorf("%s", err)
return
}
now := time.Now()
for _, agent := range status.AgentsInfo {
b, err := json.MarshalIndent(agent.Logs, "", " ")
if err != nil {
logrus.Debugf("%s", err)
b = []byte(err.Error())
}
b = append(b, '\n')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [golangci-lint] reported by reviewdog 🐶
append only allowed to cuddle with appended value (wsl)

addData(zipW, "logs/"+pointer.GetString(agent.AgentType)+".json", now, bytes.NewReader(b))
Copy link
Member

@BupycHuk BupycHuk Apr 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the reason to make it json?
I think it would be much easier to read if it would be just a text with some separator.
something like

agent id: /agent_id/xxxx1
agent type: mongodb_exporter
lorem ipsum log texts begin
...
lorem ipsum log texts
===============================================
agent id: /agent_id/xxxx2
agent type: mysqld_exporter
lorem ipsum log texts begin
...
lorem ipsum log texts

agent.Logs = nil
}

addVMAgentTargets(ctx, zipW, status.AgentsInfo)

now := time.Now()

b, err := json.MarshalIndent(status, "", " ")
if err != nil {
logrus.Debugf("%s", err)
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ require (
github.com/AlekSi/pointer v1.2.0
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d
github.com/go-openapi/runtime v0.19.20
github.com/percona/pmm v0.0.0-20211227150642-d5b782829da7
github.com/percona/pmm v0.0.0-20220402125834-c15e36d4238d
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.7.1
golang.org/x/sys v0.0.0-20200722175500-76b94024e4b6
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9
gopkg.in/alecthomas/kingpin.v2 v2.2.6
)

Expand All @@ -36,8 +36,8 @@ require (
github.com/mitchellh/mapstructure v1.3.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
go.mongodb.org/mongo-driver v1.7.1 // indirect
golang.org/x/net v0.0.0-20200707034311-ab3426394381 // indirect
golang.org/x/text v0.3.5 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
)
Loading