Skip to content

Commit

Permalink
feat(mysqlreceiver): add mysql.mysqlx_connections 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 d192223
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .chloggen/drosiek-mysql-mysqlx-metric.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.mysqlx_connections 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 @@ -21,6 +21,7 @@ These are the metrics available for this scraper.
| **mysql.index.io.wait.time** | The total time of I/O wait events for an index. | ns | Sum(Int) | <ul> <li>io_waits_operations</li> <li>table_name</li> <li>schema</li> <li>index_name</li> </ul> |
| **mysql.locks** | The number of MySQL locks. | 1 | Sum(Int) | <ul> <li>locks</li> </ul> |
| **mysql.log_operations** | The number of InnoDB log operations. | 1 | Sum(Int) | <ul> <li>log_operations</li> </ul> |
| **mysql.mysqlx_connections** | The number of mysqlx connections. This metric is specific for MySQL working as Document Store (X-Plugin). [more docs](https://dev.mysql.com/doc/refman/8.0/en/document-store.html) | 1 | Sum(Int) | <ul> <li>connection_status</li> </ul> |
| **mysql.operations** | The number of InnoDB operations. | 1 | Sum(Int) | <ul> <li>operations</li> </ul> |
| **mysql.page_operations** | The number of InnoDB page operations. | 1 | Sum(Int) | <ul> <li>page_operations</li> </ul> |
| **mysql.row_locks** | The number of InnoDB row locks. | 1 | Sum(Int) | <ul> <li>row_locks</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_status (status) | The connection status. | accepted, closed, rejected |
| 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
100 changes: 100 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.

15 changes: 15 additions & 0 deletions receiver/mysqlreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ attributes:
value: resource
description: The kind of temporary resources.
enum: [disk_tables, files, tables]
connection_status:
value: status
description: The connection status.
enum: [accepted, closed, rejected]

metrics:
mysql.buffer_pool.pages:
Expand Down Expand Up @@ -283,6 +287,17 @@ metrics:
monotonic: false
aggregation: cumulative
attributes: [threads]
mysql.mysqlx_connections:
enabled: true
description: The number of mysqlx connections.
extended_documentation: This metric is specific for MySQL working as Document Store (X-Plugin). [more docs](https://dev.mysql.com/doc/refman/8.0/en/document-store.html)
unit: 1
sum:
value_type: int
input_type: string
monotonic: true
aggregation: cumulative
attributes: [connection_status]
mysql.tmp_resources:
enabled: true
description: The number of created temporary resources.
Expand Down
8 changes: 8 additions & 0 deletions receiver/mysqlreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,14 @@ func (m *mySQLScraper) scrapeGlobalStats(now pcommon.Timestamp, errs *scrapererr
addPartialIfError(errs, m.mb.RecordMysqlThreadsDataPoint(now, v, metadata.AttributeThreadsCreated))
case "Threads_running":
addPartialIfError(errs, m.mb.RecordMysqlThreadsDataPoint(now, v, metadata.AttributeThreadsRunning))

// mysqlx_connections
case "Mysqlx_connections_accepted":
addPartialIfError(errs, m.mb.RecordMysqlMysqlxConnectionsDataPoint(now, v, metadata.AttributeConnectionStatusAccepted))
case "Mysqlx_connections_closed":
addPartialIfError(errs, m.mb.RecordMysqlMysqlxConnectionsDataPoint(now, v, metadata.AttributeConnectionStatusClosed))
case "Mysqlx_connections_rejected":
addPartialIfError(errs, m.mb.RecordMysqlMysqlxConnectionsDataPoint(now, v, metadata.AttributeConnectionStatusRejected))
}
}
}
Expand Down
50 changes: 50 additions & 0 deletions receiver/mysqlreceiver/testdata/scraper/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,56 @@
},
"unit": "ns"
},
{
"description": "The number of mysqlx connections.",
"name": "mysql.mysqlx_connections",
"sum": {
"aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE",
"isMonotonic": true,
"dataPoints": [
{
"asInt": "307",
"attributes": [
{
"key": "status",
"value": {
"stringValue": "accepted"
}
}
],
"startTimeUnixNano": "1644862687825728000",
"timeUnixNano": "1644862687825772000"
},
{
"asInt": "308",
"attributes": [
{
"key": "status",
"value": {
"stringValue": "closed"
}
}
],
"startTimeUnixNano": "1644862687825728000",
"timeUnixNano": "1644862687825772000"
},
{
"asInt": "309",
"attributes": [
{
"key": "status",
"value": {
"stringValue": "rejected"
}
}
],
"startTimeUnixNano": "1644862687825728000",
"timeUnixNano": "1644862687825772000"
}
]
},
"unit": "1"
},
{
"description": "The number of created temporary resources.",
"name": "mysql.tmp_resources",
Expand Down

0 comments on commit d192223

Please sign in to comment.