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

PMM-12375 add database version to services #2438

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
bd793d1
PMM-12375 address a deprecation warning
Aug 25, 2023
3e167ad
PMM-12375 add a Version field to CheckConnectionResponse.Stats
Aug 25, 2023
246f815
PMM-12375 extract version from different DBs
Aug 25, 2023
7eb66f3
Merge branch 'main' into PMM-12375-add-database-version-to-services
Aug 25, 2023
296d5cf
PMM-12375 revert Makefile
Aug 25, 2023
57ec9aa
Bump github.com/prometheus/alertmanager from 0.25.0 to 0.26.0 (#2436)
dependabot[bot] Aug 28, 2023
c45cc58
PMM-12375 add a column to store the version
Aug 28, 2023
f98ce11
Merge branch 'main' into PMM-12375-add-database-version-to-services
Aug 28, 2023
99b0532
PMM-12375 save version to DB
Aug 29, 2023
9d1ebec
PMM-12375 add version detection for ProxySQL
Aug 30, 2023
7348e67
PMM-12375 choose the dabase first (mysql)
Aug 30, 2023
f58949e
PMM-12375 fix syntax
Aug 30, 2023
7865feb
PMM-12375 use Exec to select a database
Aug 30, 2023
fb745dd
PMM-12375 use a different database
Aug 30, 2023
911b14d
PMM-12375 use performance_schema for higher versions
Aug 30, 2023
64715ae
PMM-12375 use a different syntax for checking the version
Aug 30, 2023
7c4b4b8
PMM-12375 quote the dashed variable
Aug 30, 2023
d8f36f4
PMM-12375 remopve --short as deprecated
Aug 31, 2023
9d7ed72
Merge branch 'main' into PMM-12375-add-database-version-to-services
Sep 7, 2023
ccb01e4
Merge branch 'main' into PMM-12375-add-database-version-to-services
Sep 11, 2023
5de5333
PMM-12375 add a dedicated message
Sep 4, 2023
ebfbb9c
PMM-12375 refactor to use a separate method for version and tableCount
Sep 12, 2023
f3bf65c
Bump github.com/grafana/grafana-api-golang-client from 0.23.0 to 0.24…
dependabot[bot] Sep 12, 2023
18806c9
PMM-12375 re-generate protobufs
Sep 12, 2023
8a7b12f
Bump @typescript-eslint/parser from 6.6.0 to 6.7.0 in /cli-tests (#2476)
dependabot[bot] Sep 12, 2023
3163ec5
Bump @typescript-eslint/eslint-plugin from 6.6.0 to 6.7.0 in /cli-tes…
dependabot[bot] Sep 12, 2023
800d582
Bump docker/login-action from 2 to 3 (#2480)
dependabot[bot] Sep 13, 2023
f2b8b95
Bump docker/setup-buildx-action from 2 to 3 (#2479)
dependabot[bot] Sep 13, 2023
fe495cc
PMM-11670 Set the cluster label if empty (#2459)
Sep 13, 2023
8008009
PMM-12376 single inventory add endpoint (#2422)
Sep 13, 2023
3e453b1
PMM-12448 Fix bug (#2437)
artemgavrilov Sep 13, 2023
002fdbb
Bump docker/build-push-action from 4 to 5 (#2481)
dependabot[bot] Sep 13, 2023
0697b04
PMM-12457 add node_name to agent metrics (#2474)
Sep 13, 2023
b2e10bc
PMM-12488 update VictoriaMetrics to v1.93.4 (#2483)
Sep 15, 2023
0b52509
PMM-9769 update all components (#2478)
talhabinrizwan Sep 15, 2023
06d99a8
PMM-12375 add version prop to ProxySQL service
Sep 15, 2023
f1a259a
PMM-12375 move GetInfoFromService to serviceInfoBroker
Sep 16, 2023
d9cc8e4
Merge branch 'main' into PMM-12375-add-database-version-to-services
Sep 16, 2023
8595ae6
PMM-12375 fix service_test.go by adding params
Sep 16, 2023
e621aca
PMM-12375 remove Stats from agent.proto
Sep 16, 2023
f5ad29e
PMM-12375 fix the linter error
Sep 16, 2023
c89d862
PMM-12375 clean up serviceInfoBroker component
Sep 16, 2023
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
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ linters:
- nlreturn # too annoying
- nosnakecase # deprecated
- scopelint # too many false positives
- structcheck # replaced by unused
Copy link
Member Author

Choose a reason for hiding this comment

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

This will silence the linter's deprecation warnings.

- varcheck # replaced by unused
- varnamelen # useless
- wrapcheck # we do not use wrapping everywhere
- wsl # too annoying
Expand Down
2 changes: 1 addition & 1 deletion admin/commands/management/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

// AddCommand is used by Kong for CLI flags and commands.
type AddCommand struct {
External AddExternalCommand `cmd:"" help:"Add External source of data (like a custom exporter running on a port) to the monitoring"`
External AddExternalCommand `cmd:"" help:"Add External source of data (like a custom exporter running on a port) to monitoring"`
ExternalServerless AddExternalServerlessCommand `cmd:"" help:"Add External Service on Remote node to monitoring"`
HAProxy AddHAProxyCommand `cmd:"" name:"haproxy" help:"Add HAProxy to monitoring"`
MongoDB AddMongoDBCommand `cmd:"" name:"mongodb" help:"Add MongoDB to monitoring"`
Expand Down
53 changes: 53 additions & 0 deletions agent/connectionchecker/connection_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,15 @@ func (cc *ConnectionChecker) checkMySQLConnection(ctx context.Context, dsn strin
tableCount = math.MaxInt32
}

var version string
if err = db.QueryRowContext(ctx, "SELECT /* agent='connectionchecker' */ VERSION()").Scan(&version); err != nil {
res.Error = err.Error()
return &res
}

res.Stats = &agentpb.CheckConnectionResponse_Stats{
TableCount: tableCount,
Version: version,
}

return &res
Expand Down Expand Up @@ -201,6 +208,25 @@ func (cc *ConnectionChecker) checkMongoDBConnection(ctx context.Context, dsn str
return &res
}

resp = client.Database("admin").RunCommand(ctx, bson.D{{Key: "buildInfo", Value: 1}})
if err = resp.Err(); err != nil {
res.Error = err.Error()
return &res
}

buildInfo := struct {
Version string `bson:"version"`
}{}

if err = resp.Decode(&buildInfo); err != nil {
cc.l.Debugf("checkMongoDBConnection: failed to decode buildInfo: %s", err)
return &res
}

res.Stats = &agentpb.CheckConnectionResponse_Stats{
Version: buildInfo.Version,
}

return &res
}

Expand Down Expand Up @@ -228,6 +254,16 @@ func (cc *ConnectionChecker) checkPostgreSQLConnection(ctx context.Context, dsn
res.Error = err.Error()
}

var version string
if err = db.QueryRowContext(ctx, "SHOW /* agent='connectionchecker' */ SERVER_VERSION").Scan(&version); err != nil {
res.Error = err.Error()
return &res
}

res.Stats = &agentpb.CheckConnectionResponse_Stats{
Version: version,
}

return &res
}

Expand All @@ -253,6 +289,23 @@ func (cc *ConnectionChecker) checkProxySQLConnection(ctx context.Context, dsn st
res.Error = err.Error()
}

// if _, err := db.ExecContext(ctx, "USE mysql"); err != nil {
// res.Error = err.Error()
// return &res
// }

var version string
if err := db.QueryRowContext(
ademidoff marked this conversation as resolved.
Show resolved Hide resolved
ctx,
"SELECT /* agent='connectionchecker' */ variable_value FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE variable_name = 'admin-version'").Scan(&version); err != nil {
ademidoff marked this conversation as resolved.
Show resolved Hide resolved
res.Error = err.Error()
return &res
}

res.Stats = &agentpb.CheckConnectionResponse_Stats{
Version: version,
}

return &res
}

Expand Down
830 changes: 420 additions & 410 deletions api/agentpb/agent.pb.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions api/agentpb/agent.pb.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/agentpb/agent.proto
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ message CheckConnectionResponse {
message Stats {
// A number of tables, 0 if unknown.
int32 table_count = 1;
string version = 2;
}
// Error message if connection check failed.
string error = 1;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions api/inventorypb/json/inventorypb.json
Original file line number Diff line number Diff line change
Expand Up @@ -11066,6 +11066,11 @@
"description": "Access unix socket.\nAddress (and port) or socket is required.",
"type": "string",
"x-order": 5
},
"version": {
"description": "MongoDB version.",
"type": "string",
"x-order": 10
}
},
"x-order": 0
Expand Down Expand Up @@ -11239,6 +11244,11 @@
"description": "Access unix socket.\nAddress (and port) or socket is required.",
"type": "string",
"x-order": 5
},
"version": {
"description": "MySQL version.",
"type": "string",
"x-order": 10
}
},
"x-order": 0
Expand Down Expand Up @@ -11417,6 +11427,11 @@
"description": "Access unix socket.\nAddress (and port) or socket is required.",
"type": "string",
"x-order": 6
},
"version": {
"description": "PostgreSQL version.",
"type": "string",
"x-order": 11
}
},
"x-order": 0
Expand Down Expand Up @@ -12043,6 +12058,11 @@
"description": "Access unix socket.\nAddress (and port) or socket is required.",
"type": "string",
"x-order": 5
},
"version": {
"description": "MongoDB version.",
"type": "string",
"x-order": 10
}
},
"x-order": 1
Expand Down Expand Up @@ -12104,6 +12124,11 @@
"description": "Access unix socket.\nAddress (and port) or socket is required.",
"type": "string",
"x-order": 5
},
"version": {
"description": "MySQL version.",
"type": "string",
"x-order": 10
}
},
"x-order": 0
Expand Down Expand Up @@ -12170,6 +12195,11 @@
"description": "Access unix socket.\nAddress (and port) or socket is required.",
"type": "string",
"x-order": 6
},
"version": {
"description": "PostgreSQL version.",
"type": "string",
"x-order": 11
}
},
"x-order": 2
Expand Down Expand Up @@ -12483,6 +12513,11 @@
"description": "Access unix socket.\nAddress (and port) or socket is required.",
"type": "string",
"x-order": 5
},
"version": {
"description": "MongoDB version.",
"type": "string",
"x-order": 10
}
}
},
Expand Down Expand Up @@ -12547,6 +12582,11 @@
"description": "Access unix socket.\nAddress (and port) or socket is required.",
"type": "string",
"x-order": 5
},
"version": {
"description": "MySQL version.",
"type": "string",
"x-order": 10
}
}
},
Expand Down Expand Up @@ -12616,6 +12656,11 @@
"description": "Access unix socket.\nAddress (and port) or socket is required.",
"type": "string",
"x-order": 6
},
"version": {
"description": "PostgreSQL version.",
"type": "string",
"x-order": 11
}
}
},
Expand Down
Loading
Loading