Merge pull request #4208 from influxdb/show_diag_m
Support module-selection for SHOW DIAGNOSTICSpull/4160/head^2
commit
2188a670fa
|
@ -6,6 +6,7 @@
|
|||
- [#4140](https://github.com/influxdb/influxdb/pull/4140): Make storage engine configurable
|
||||
- [#4161](https://github.com/influxdb/influxdb/pull/4161): Implement bottom selector function
|
||||
- [#4204](https://github.com/influxdb/influxdb/pull/4204): Allow module-level selection for SHOW STATS
|
||||
- [#4208](https://github.com/influxdb/influxdb/pull/4208): Allow module-level selection for SHOW DIAGNOSTICS
|
||||
- [#4196](https://github.com/influxdb/influxdb/pull/4196): Export tsdb.Iterator
|
||||
- [#4198](https://github.com/influxdb/influxdb/pull/4198): Add basic cluster-service stats
|
||||
|
||||
|
|
|
@ -1999,6 +1999,7 @@ func (s *ShowStatsStatement) String() string {
|
|||
var buf bytes.Buffer
|
||||
_, _ = buf.WriteString("SHOW STATS ")
|
||||
if s.Module != "" {
|
||||
_, _ = buf.WriteString("FOR ")
|
||||
_, _ = buf.WriteString(s.Module)
|
||||
}
|
||||
return buf.String()
|
||||
|
@ -2021,10 +2022,21 @@ func (s *ShowShardsStatement) RequiredPrivileges() ExecutionPrivileges {
|
|||
}
|
||||
|
||||
// ShowDiagnosticsStatement represents a command for show node diagnostics.
|
||||
type ShowDiagnosticsStatement struct{}
|
||||
type ShowDiagnosticsStatement struct {
|
||||
// Module
|
||||
Module string
|
||||
}
|
||||
|
||||
// String returns a string representation of the ShowDiagnosticsStatement.
|
||||
func (s *ShowDiagnosticsStatement) String() string { return "SHOW DIAGNOSTICS" }
|
||||
func (s *ShowDiagnosticsStatement) String() string {
|
||||
var buf bytes.Buffer
|
||||
_, _ = buf.WriteString("SHOW DIAGNOSTICS ")
|
||||
if s.Module != "" {
|
||||
_, _ = buf.WriteString("FOR ")
|
||||
_, _ = buf.WriteString(s.Module)
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
// RequiredPrivileges returns the privilege required to execute a ShowDiagnosticsStatement
|
||||
func (s *ShowDiagnosticsStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
|
|
|
@ -1445,7 +1445,15 @@ func (p *Parser) parseShowStatsStatement() (*ShowStatsStatement, error) {
|
|||
// parseShowDiagnostics parses a string and returns a ShowDiagnosticsStatement.
|
||||
func (p *Parser) parseShowDiagnosticsStatement() (*ShowDiagnosticsStatement, error) {
|
||||
stmt := &ShowDiagnosticsStatement{}
|
||||
return stmt, nil
|
||||
var err error
|
||||
|
||||
if tok, _, _ := p.scanIgnoreWhitespace(); tok == FOR {
|
||||
stmt.Module, err = p.parseString()
|
||||
} else {
|
||||
p.unscan()
|
||||
}
|
||||
|
||||
return stmt, err
|
||||
}
|
||||
|
||||
// parseDropContinuousQueriesStatement parses a string and returns a DropContinuousQueryStatement.
|
||||
|
|
|
@ -1417,6 +1417,12 @@ func TestParser_ParseStatement(t *testing.T) {
|
|||
s: `SHOW DIAGNOSTICS`,
|
||||
stmt: &influxql.ShowDiagnosticsStatement{},
|
||||
},
|
||||
{
|
||||
s: `SHOW DIAGNOSTICS FOR 'build'`,
|
||||
stmt: &influxql.ShowDiagnosticsStatement{
|
||||
Module: "build",
|
||||
},
|
||||
},
|
||||
|
||||
// Errors
|
||||
{s: ``, err: `found EOF, expected SELECT, DELETE, SHOW, CREATE, DROP, GRANT, REVOKE, ALTER, SET at line 1, char 1`},
|
||||
|
@ -1501,6 +1507,7 @@ func TestParser_ParseStatement(t *testing.T) {
|
|||
{s: `SHOW RETENTION POLICIES ON`, err: `found EOF, expected identifier at line 1, char 28`},
|
||||
{s: `SHOW FOO`, err: `found FOO, expected CONTINUOUS, DATABASES, FIELD, GRANTS, MEASUREMENTS, RETENTION, SERIES, SERVERS, TAG, USERS at line 1, char 6`},
|
||||
{s: `SHOW STATS FOR`, err: `found EOF, expected string at line 1, char 16`},
|
||||
{s: `SHOW DIAGNOSTICS FOR`, err: `found EOF, expected string at line 1, char 22`},
|
||||
{s: `SHOW GRANTS`, err: `found EOF, expected FOR at line 1, char 13`},
|
||||
{s: `SHOW GRANTS FOR`, err: `found EOF, expected identifier at line 1, char 17`},
|
||||
{s: `DROP CONTINUOUS`, err: `found EOF, expected QUERY at line 1, char 17`},
|
||||
|
|
|
@ -14,7 +14,7 @@ An example of statistical information would be the number of points received ove
|
|||
All statistics are written, by default, by each node to a "monitor" database within the InfluxDB system, allowing analysis of aggregated statistical data using the standard InfluxQL language. This allows users to track the performance of their system. Importantly, this allows cluster-level statistics to be viewed, since by querying the monitor database, statistics from all nodes may be queried. This can be a very powerful approach for troubleshooting your InfluxDB system and understanding its behaviour.
|
||||
|
||||
## System Diagnostics
|
||||
`SHOW DIAGNOSTICS` displays various diagnostic information about the `influxd` process. This information is not stored persistently within the InfluxDB system.
|
||||
`SHOW DIAGNOSTICS [FOR <module>]` displays various diagnostic information about the `influxd` process. This information is not stored persistently within the InfluxDB system. If _module_ is specified, it must be single-quoted. For example `SHOW STATS FOR 'build'`.
|
||||
|
||||
## Standard expvar support
|
||||
All statistical information is available at HTTP API endpoint `/debug/vars`, in [expvar](https://golang.org/pkg/expvar/) format, allowing external systems to monitor an InfluxDB node. By default, the full path to this endpoint is `http://localhost:8086/debug/vars`.
|
||||
|
|
|
@ -21,7 +21,7 @@ func (s *StatementExecutor) ExecuteStatement(stmt influxql.Statement) *influxql.
|
|||
case *influxql.ShowStatsStatement:
|
||||
return s.executeShowStatistics(stmt.Module)
|
||||
case *influxql.ShowDiagnosticsStatement:
|
||||
return s.executeShowDiagnostics()
|
||||
return s.executeShowDiagnostics(stmt.Module)
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported statement type: %T", stmt))
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ func (s *StatementExecutor) executeShowStatistics(module string) *influxql.Resul
|
|||
return &influxql.Result{Series: rows}
|
||||
}
|
||||
|
||||
func (s *StatementExecutor) executeShowDiagnostics() *influxql.Result {
|
||||
func (s *StatementExecutor) executeShowDiagnostics(module string) *influxql.Result {
|
||||
diags, err := s.Monitor.Diagnostics()
|
||||
if err != nil {
|
||||
return &influxql.Result{Err: err}
|
||||
|
@ -59,6 +59,10 @@ func (s *StatementExecutor) executeShowDiagnostics() *influxql.Result {
|
|||
rows := make([]*models.Row, 0, len(diags))
|
||||
|
||||
for k, v := range diags {
|
||||
if module != "" && k != module {
|
||||
continue
|
||||
}
|
||||
|
||||
row := &models.Row{Name: k}
|
||||
|
||||
row.Columns = v.Columns
|
||||
|
|
Loading…
Reference in New Issue