Skip to content

Commit

Permalink
feat(mysqlreceiver): Add mysql.connection.errors metric
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Rosiek <drosiek@sumologic.com>
  • Loading branch information
Dominik Rosiek committed Oct 11, 2022
1 parent 6dc71bd commit e2f8c34
Show file tree
Hide file tree
Showing 6 changed files with 253 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .chloggen/drosiek-mysql-connection-errors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: mysqlreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add mysql.connection.errors metric

# One or more tracking issues related to the change
issues: [14138]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
2 changes: 2 additions & 0 deletions receiver/mysqlreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ These are the metrics available for this scraper.
| **mysql.buffer_pool.pages** | The number of pages in the InnoDB buffer pool. | 1 | Sum(Int) | <ul> <li>buffer_pool_pages</li> </ul> |
| **mysql.buffer_pool.usage** | The number of bytes in the InnoDB buffer pool. | By | Sum(Int) | <ul> <li>buffer_pool_data</li> </ul> |
| **mysql.commands** | The number of times each type of command has been executed. | 1 | Sum(Int) | <ul> <li>command</li> </ul> |
| **mysql.connection.errors** | Errors that occur during the client connection process. | 1 | Sum(Int) | <ul> <li>connection_error</li> </ul> |
| **mysql.double_writes** | The number of writes to the InnoDB doublewrite buffer. | 1 | Sum(Int) | <ul> <li>double_writes</li> </ul> |
| **mysql.handlers** | The number of requests to various MySQL handlers. | 1 | Sum(Int) | <ul> <li>handler</li> </ul> |
| **mysql.index.io.wait.count** | The total count of I/O wait events for an index. | 1 | Sum(Int) | <ul> <li>io_waits_operations</li> <li>table_name</li> <li>schema</li> <li>index_name</li> </ul> |
Expand Down Expand Up @@ -54,6 +55,7 @@ metrics:
| buffer_pool_operations (operation) | The buffer pool operations types. | read_ahead_rnd, read_ahead, read_ahead_evicted, read_requests, reads, wait_free, write_requests |
| buffer_pool_pages (kind) | The buffer pool pages types. | data, free, misc |
| command (command) | The command types. | execute, close, fetch, prepare, reset, send_long_data |
| connection_error (error) | The connection error type. | accept, internal, max_connections, peer_address, select, tcpwrap |
| double_writes (kind) | The doublewrite types. | pages_written, writes |
| handler (kind) | The handler types. | commit, delete, discover, external_lock, mrr_init, prepare, read_first, read_key, read_last, read_next, read_prev, read_rnd, read_rnd_next, rollback, savepoint, savepoint_rollback, update, write |
| index_name (index) | The name of the index. | |
Expand Down
112 changes: 112 additions & 0 deletions receiver/mysqlreceiver/internal/metadata/generated_metrics.go

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

14 changes: 14 additions & 0 deletions receiver/mysqlreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ attributes:
value: command
description: The command types.
enum: [execute, close, fetch, prepare, reset, send_long_data]
connection_error:
value: error
description: The connection error type.
enum: [accept, internal, max_connections, peer_address, select, tcpwrap]
handler:
value: kind
description: The handler types.
Expand Down Expand Up @@ -283,6 +287,16 @@ metrics:
monotonic: false
aggregation: cumulative
attributes: [threads]
mysql.connection.errors:
enabled: true
description: Errors that occur during the client connection process.
unit: 1
sum:
value_type: int
input_type: string
monotonic: true
aggregation: cumulative
attributes: [connection_error]
mysql.tmp_resources:
enabled: true
description: The number of created temporary resources.
Expand Down
20 changes: 20 additions & 0 deletions receiver/mysqlreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,26 @@ func (m *mySQLScraper) scrapeGlobalStats(now pcommon.Timestamp, errs *scrapererr
addPartialIfError(errs, m.mb.RecordMysqlBufferPoolOperationsDataPoint(now, v,
metadata.AttributeBufferPoolOperationsWriteRequests))

// connection.errors
case "Connection_errors_accept":
addPartialIfError(errs, m.mb.RecordMysqlConnectionErrorsDataPoint(now, v,
metadata.AttributeConnectionErrorAccept))
case "Connection_errors_internal":
addPartialIfError(errs, m.mb.RecordMysqlConnectionErrorsDataPoint(now, v,
metadata.AttributeConnectionErrorInternal))
case "Connection_errors_max_connections":
addPartialIfError(errs, m.mb.RecordMysqlConnectionErrorsDataPoint(now, v,
metadata.AttributeConnectionErrorMaxConnections))
case "Connection_errors_peer_address":
addPartialIfError(errs, m.mb.RecordMysqlConnectionErrorsDataPoint(now, v,
metadata.AttributeConnectionErrorPeerAddress))
case "Connection_errors_select":
addPartialIfError(errs, m.mb.RecordMysqlConnectionErrorsDataPoint(now, v,
metadata.AttributeConnectionErrorSelect))
case "Connection_errors_tcpwrap":
addPartialIfError(errs, m.mb.RecordMysqlConnectionErrorsDataPoint(now, v,
metadata.AttributeConnectionErrorTcpwrap))

// commands
case "Com_stmt_execute":
addPartialIfError(errs, m.mb.RecordMysqlCommandsDataPoint(now, v, metadata.AttributeCommandExecute))
Expand Down
89 changes: 89 additions & 0 deletions receiver/mysqlreceiver/testdata/scraper/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,95 @@
},
"unit": "1"
},
{
"description": "Errors that occur during the client connection process.",
"name": "mysql.connection.errors",
"sum": {
"aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE",
"dataPoints": [
{
"asInt": "182",
"attributes": [
{
"key": "error",
"value": {
"stringValue": "accept"
}
}
],
"startTimeUnixNano": "1644862687825728000",
"timeUnixNano": "1644862687825772000"
},
{
"asInt": "183",
"attributes": [
{
"key": "error",
"value": {
"stringValue": "internal"
}
}
],
"startTimeUnixNano": "1644862687825728000",
"timeUnixNano": "1644862687825772000"
},
{
"asInt": "184",
"attributes": [
{
"key": "error",
"value": {
"stringValue": "max_connections"
}
}
],
"startTimeUnixNano": "1644862687825728000",
"timeUnixNano": "1644862687825772000"
},
{
"asInt": "185",
"attributes": [
{
"key": "error",
"value": {
"stringValue": "peer_address"
}
}
],
"startTimeUnixNano": "1644862687825728000",
"timeUnixNano": "1644862687825772000"
},
{
"asInt": "186",
"attributes": [
{
"key": "error",
"value": {
"stringValue": "select"
}
}
],
"startTimeUnixNano": "1644862687825728000",
"timeUnixNano": "1644862687825772000"
},
{
"asInt": "187",
"attributes": [
{
"key": "error",
"value": {
"stringValue": "tcpwrap"
}
}
],
"startTimeUnixNano": "1644862687825728000",
"timeUnixNano": "1644862687825772000"
}
],
"isMonotonic": true
},
"unit": "1"
},
{
"description": "The number of writes to the InnoDB doublewrite buffer.",
"name": "mysql.double_writes",
Expand Down

0 comments on commit e2f8c34

Please sign in to comment.