-
Notifications
You must be signed in to change notification settings - Fork 32
feat(support-mysql-8): Added support for mysql version 8.0 and above #170
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
Changes from 1 commit
62e1c0a
fe29f92
5f06db8
9bb9fc1
a30f337
18429fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
package main | ||
sairaj18 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import ( | ||
"github.com/blang/semver/v4" | ||
"github.com/newrelic/infra-integrations-sdk/v3/data/metric" | ||
) | ||
|
||
var defaultMetricsBase = map[string][]interface{}{ | ||
"net.abortedClientsPerSecond": {"Aborted_clients", metric.RATE}, | ||
"net.abortedConnectsPerSecond": {"Aborted_connects", metric.RATE}, | ||
"net.bytesReceivedPerSecond": {"Bytes_received", metric.RATE}, | ||
"net.bytesSentPerSecond": {"Bytes_sent", metric.RATE}, | ||
"net.connectionErrorsMaxConnectionsPerSecond": {"Connection_errors_max_connections", metric.RATE}, | ||
"net.connectionsPerSecond": {"Connections", metric.RATE}, | ||
"net.maxUsedConnections": {"Max_used_connections", metric.GAUGE}, | ||
"net.threadsConnected": {"Threads_connected", metric.GAUGE}, | ||
"net.threadsRunning": {"Threads_running", metric.GAUGE}, | ||
"query.comCommitPerSecond": {"Com_commit", metric.RATE}, | ||
"query.comDeletePerSecond": {"Com_delete", metric.RATE}, | ||
"query.comDeleteMultiPerSecond": {"Com_delete_multi", metric.RATE}, | ||
"query.comInsertPerSecond": {"Com_insert", metric.RATE}, | ||
"query.comInsertSelectPerSecond": {"Com_insert_select", metric.RATE}, | ||
"query.comReplaceSelectPerSecond": {"Com_replace_select", metric.RATE}, | ||
"query.comRollbackPerSecond": {"Com_rollback", metric.RATE}, | ||
"query.comSelectPerSecond": {"Com_select", metric.RATE}, | ||
"query.comUpdatePerSecond": {"Com_update", metric.RATE}, | ||
"query.comUpdateMultiPerSecond": {"Com_update_multi", metric.RATE}, | ||
"db.handlerRollbackPerSecond": {"Handler_rollback", metric.RATE}, | ||
"query.preparedStmtCountPerSecond": {"Prepared_stmt_count", metric.RATE}, | ||
"query.queriesPerSecond": {"Queries", metric.RATE}, | ||
"query.questionsPerSecond": {"Questions", metric.RATE}, | ||
"query.slowQueriesPerSecond": {"Slow_queries", metric.RATE}, | ||
"db.innodb.bufferPoolPagesData": {"Innodb_buffer_pool_pages_data", metric.GAUGE}, | ||
"db.innodb.bufferPoolPagesFree": {"Innodb_buffer_pool_pages_free", metric.GAUGE}, | ||
"db.innodb.bufferPoolPagesTotal": {"Innodb_buffer_pool_pages_total", metric.GAUGE}, | ||
"db.innodb.dataReadBytesPerSecond": {"Innodb_data_read", metric.RATE}, | ||
"db.innodb.dataWrittenBytesPerSecond": {"Innodb_data_written", metric.RATE}, | ||
"db.innodb.logWaitsPerSecond": {"Innodb_log_waits", metric.RATE}, | ||
"db.innodb.rowLockCurrentWaits": {"Innodb_row_lock_current_waits", metric.GAUGE}, | ||
"db.innodb.rowLockTimeAvg": {"Innodb_row_lock_time_avg", metric.GAUGE}, | ||
"db.innodb.rowLockWaitsPerSecond": {"Innodb_row_lock_waits", metric.RATE}, | ||
"db.openFiles": {"Open_files", metric.GAUGE}, | ||
"db.openTables": {"Open_tables", metric.GAUGE}, | ||
"db.openedTablesPerSecond": {"Opened_tables", metric.RATE}, | ||
"db.tablesLocksWaitedPerSecond": {"Table_locks_waited", metric.RATE}, | ||
"software.edition": {"version_comment", metric.ATTRIBUTE}, | ||
"software.version": {"version", metric.ATTRIBUTE}, | ||
"cluster.nodeType": {"node_type", metric.ATTRIBUTE}, | ||
} | ||
|
||
var defaultMetrics560 = map[string][]interface{}{ | ||
sairaj18 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"db.qCacheFreeMemoryBytes": {"Qcache_free_memory", metric.GAUGE}, | ||
"db.qCacheNotCachedPerSecond": {"Qcache_not_cached", metric.RATE}, | ||
"db.qCacheUtilization": {qCacheUtilization, metric.GAUGE}, | ||
"db.qCacheHitRatio": {qCacheHitRatio, metric.GAUGE}, | ||
// If a cluster instance is not a slave, then the metric cluster.slaveRunning will be removed. | ||
"cluster.slaveRunning": {slaveRunningAsNumber, metric.GAUGE}, | ||
} | ||
|
||
var defaultMetrics800 = map[string][]interface{}{ | ||
// If a cluster instance is not a slave, then the metric cluster.slaveRunning will be removed. | ||
"cluster.slaveRunning": {slaveRunningAsNumber, metric.GAUGE}, | ||
} | ||
|
||
func slaveRunningAsNumber(metrics map[string]interface{}, version *semver.Version) (int, bool) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this requires unit tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is already existing func just moved to diff file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it is not possible to add unit test for this as part of this PR, please create a task for adding it later. |
||
var prefix string | ||
if version.GE(semver.Version{Major: 8, Minor: 0, Patch: 0}) { | ||
prefix = "Replica" | ||
} else { | ||
prefix = "Slave" | ||
} | ||
slaveIORunning, okIO := metrics[prefix+"_IO_Running"].(string) | ||
slaveSQLRunning, okSQL := metrics[prefix+"_SQL_Running"].(string) | ||
if !okIO || !okSQL { | ||
return 0, false | ||
} | ||
if slaveIORunning == "Yes" && slaveSQLRunning == "Yes" { | ||
return 1, true | ||
} | ||
return 0, true | ||
} | ||
|
||
func qCacheUtilization(metrics map[string]interface{}) (float64, bool) { | ||
// TODO compute the value within the interval | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This TODO is not clear to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is already existing comment that just moved to different file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to understand why it is there. If we think we don't need it, it can be removed. |
||
qCacheFreeBlocks, ok1 := metrics["Qcache_free_blocks"].(int) | ||
qCacheTotalBlocks, ok2 := metrics["Qcache_total_blocks"].(int) | ||
|
||
if qCacheTotalBlocks == 0 { | ||
return 0, true | ||
} else if ok1 && ok2 { | ||
return 1 - (float64(qCacheFreeBlocks) / float64(qCacheTotalBlocks)), true | ||
} | ||
return 0, false | ||
} | ||
|
||
func qCacheHitRatio(metrics map[string]interface{}) (float64, bool) { | ||
qCacheHits, ok1 := metrics["Qcache_hits"].(int) | ||
queries, ok2 := metrics["Queries"].(int) | ||
|
||
if queries == 0 { | ||
return 0, true | ||
} else if ok1 && ok2 { | ||
sairaj18 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return float64(qCacheHits) / float64(queries), true | ||
} | ||
return 0, false | ||
} | ||
|
||
var defaultMetricsVersionDefinitions = []VersionDefinition{ | ||
{ | ||
minVersion: semver.MustParse("8.0.0"), | ||
metricsDefinition: mergeMaps(defaultMetricsBase, defaultMetrics800), | ||
sairaj18 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
{ | ||
minVersion: semver.MustParse("5.6.0"), | ||
metricsDefinition: mergeMaps(defaultMetricsBase, defaultMetrics560), | ||
sairaj18 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
} | ||
|
||
func getDefaultMetrics(version *semver.Version) map[string][]interface{} { | ||
// Find the first version definition that's applicable | ||
for _, versionDef := range defaultMetricsVersionDefinitions { | ||
if version.GE(versionDef.minVersion) { | ||
return versionDef.metricsDefinition | ||
} | ||
} | ||
return defaultMetricsBase | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package main | ||
sairaj18 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import ( | ||
"github.com/blang/semver/v4" | ||
"github.com/newrelic/infra-integrations-sdk/v3/data/metric" | ||
) | ||
|
||
var extendedMetricsBase = map[string][]interface{}{ | ||
"db.createdTmpDiskTablesPerSecond": {"Created_tmp_disk_tables", metric.RATE}, | ||
"db.createdTmpFilesPerSecond": {"Created_tmp_files", metric.RATE}, | ||
"db.createdTmpTablesPerSecond": {"Created_tmp_tables", metric.RATE}, | ||
"db.handlerDeletePerSecond": {"Handler_delete", metric.RATE}, | ||
"db.handlerReadFirstPerSecond": {"Handler_read_first", metric.RATE}, | ||
"db.handlerReadKeyPerSecond": {"Handler_read_key", metric.RATE}, | ||
"db.handlerReadRndPerSecond": {"Handler_read_rnd", metric.RATE}, | ||
"db.handlerReadRndNextPerSecond": {"Handler_read_rnd_next", metric.RATE}, | ||
"db.handlerUpdatePerSecond": {"Handler_update", metric.RATE}, | ||
"db.handlerWritePerSecond": {"Handler_write", metric.RATE}, | ||
"db.maxExecutionTimeExceededPerSecond": {"Max_execution_time_exceeded", metric.RATE}, | ||
"db.selectFullJoinPerSecond": {"Select_full_join", metric.RATE}, | ||
"db.selectFullJoinRangePerSecond": {"Select_full_range_join", metric.RATE}, | ||
"db.selectRangePerSecond": {"Select_range", metric.RATE}, | ||
"db.selectRangeCheckPerSecond": {"Select_range_check", metric.RATE}, | ||
"db.sortMergePassesPerSecond": {"Sort_merge_passes", metric.RATE}, | ||
"db.sortRangePerSecond": {"Sort_range", metric.RATE}, | ||
"db.sortRowsPerSecond": {"Sort_rows", metric.RATE}, | ||
"db.sortScanPerSecond": {"Sort_scan", metric.RATE}, | ||
"db.tableOpenCacheHitsPerSecond": {"Table_open_cache_hits", metric.RATE}, | ||
"db.tableOpenCacheMissesPerSecond": {"Table_open_cache_misses", metric.RATE}, | ||
"db.tableOpenCacheOverflowsPerSecond": {"Table_open_cache_overflows", metric.RATE}, | ||
"db.threadsCached": {"Threads_cached", metric.GAUGE}, | ||
"db.threadsCreatedPerSecond": {"Threads_created", metric.RATE}, | ||
"db.threadCacheMissRate": {threadCacheMissRate, metric.GAUGE}, | ||
} | ||
|
||
var extendedMetrics560 = map[string][]interface{}{ | ||
"db.qCacheFreeBlocks": {"Qcache_free_blocks", metric.GAUGE}, | ||
"db.qCacheHitsPerSecond": {"Qcache_hits", metric.RATE}, | ||
"db.qCacheInserts": {"Qcache_inserts", metric.GAUGE}, | ||
"db.qCacheLowmemPrunesPerSecond": {"Qcache_lowmem_prunes", metric.RATE}, | ||
"db.qCacheQueriesInCachePerSecond": {"Qcache_queries_in_cache", metric.RATE}, | ||
"db.qCacheTotalBlocks": {"Qcache_total_blocks", metric.GAUGE}, | ||
} | ||
|
||
func threadCacheMissRate(metrics map[string]interface{}) (float64, bool) { | ||
// TODO compute the value within the interval | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't understand the TODO statement here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is already existing comment that just moved to different file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to understand why it is there. If we think we don't need it, it can be removed. |
||
threadsCreated, ok1 := metrics["Threads_created"].(int) | ||
connections, ok2 := metrics["Connections"].(int) | ||
|
||
if connections == 0 { | ||
return 0, true | ||
} else if ok1 && ok2 { | ||
return float64(threadsCreated) / float64(connections), true | ||
} | ||
return 0, false | ||
} | ||
|
||
var extendedMetricsVersionDefinitions = []VersionDefinition{ | ||
{ | ||
minVersion: semver.MustParse("8.0.0"), | ||
metricsDefinition: extendedMetricsBase, | ||
}, | ||
{ | ||
minVersion: semver.MustParse("5.6.0"), | ||
metricsDefinition: mergeMaps(extendedMetricsBase, extendedMetrics560), | ||
sairaj18 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
} | ||
|
||
func getExtendedMetrics(version *semver.Version) map[string][]interface{} { | ||
// Find the first version definition that's applicable | ||
for _, versionDef := range extendedMetricsVersionDefinitions { | ||
if version.GE(versionDef.minVersion) { | ||
return versionDef.metricsDefinition | ||
} | ||
} | ||
return extendedMetricsBase | ||
} |
Uh oh!
There was an error while loading. Please reload this page.