MattHodge/Graphite-PowerShell-Functions

Dynamic lists on SQL metrics.

kasperbrandenburg opened this issue · 1 comments

Hi,

Would it be possible to change the SQLMetric collection to multiple rows in the resultset.
E.g. grabbing multiple performance counters from dm_os_performance_counters
and also generating the Graphite metric based on SQL resultset instead of having it hardcoded in the configXML

SELECT
GETDATE() AS LogDate
, object_name AS object_name
, CASE instance_name WHEN '' THEN '_Total' ELSE instance_name END AS instance_name
, counter_name AS counter_name
, cntr_value AS cntr_value
FROM
sys.dm_os_performance_counters WITH (NOLOCK)

                # Run the SQL Command
                try
                {
                    $commandMeasurement = Measure-Command -Expression {
                        $sqlresult = Invoke-SQLCmd @sqlCmdParams

                        # Build the MetricPath that will be used to send the metric to Graphite
                        $metricPath = $Config.MSSQLMetricPath + '.' + $query.MetricName

                        $metricsToSend[$metricPath] = $sqlresult[0]
                    }

I created a pull-request for this :)
#47