Skip to content
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

Retrieving statistics #177

Open
MarkMorsing opened this issue Dec 3, 2024 · 3 comments
Open

Retrieving statistics #177

MarkMorsing opened this issue Dec 3, 2024 · 3 comments

Comments

@MarkMorsing
Copy link

I'm attempting to pull out statistics via the powershell commandlet - but i can't seem to figure it out.
I've tried reading through the commands and the "documentation" but i simply can't figure out how to pull out link statistics, memory statistics and power statistics .

I've found the metric explorer:
Get-IntersightMetricsMetricsExploration
https://github.com/CiscoDevNet/intersight-powershell/blob/main/docs/Set-IntersightMetricsMetricsExploration.md

But i can't actually find any results...

Has anyone actually managed to retrieve statistics via API?

@jingiris05
Copy link

You can retrieve statistics such as link, memory, and power metrics using the IntersightMetricsMetricsExploration cmdlet. Below are examples for each type of statistic:

Link Statistics:
$MetricCriteria11 = Initialize-IntersightMetricsMetricCriterion -Aggregation "" -Filters @() -Groups @() -Instrument "hw.network" -IsEnabled $true -Metric "hw.network.up_max" -MetricAggregation "Max" -TopLimit 5
$VisualConfig1 = '{"chartType":"line","dashboardInstance":{"instanceId":"line:metricsExploration","notFilterable":true,"srcTypes":[{"customOptions":{"srcTypes":"metricsExploration","title":"Test-linkStatus"},"instanceId":"line:metricsExploration","options":{"explorationModel":{"Granularity":"PT10M","Intervals":"last.day","MetricCriteria":[{"Aggregation":"","Filters":[],"Groups":[],"Instrument":"hw.network","IsEnabled":true,"Metric":"hw.network.up_max","MetricAggregation":"Max","TopLimit":5,"TopSort":"Dsc"}],"Name":"","VisualConfig":{"chartType":"line","displayOptions":[{"Metric":"hw.network.up_max","id":"hw-network-up_max-Max","yAxis":"left"}]},"id":"2024-12-17T13:01:38.765Z"},"format":{"basedOnInterval":true},"granularity":"PT10M","interval":"last.day","legend":{"position":"bottom"},"mappings":{"xAxisPath":"timestamp","y":{"ids":["hw-network-up_max-Max"],"postfixLabelPath":"result.$index.postfixValue","scale":"linear","units":"","y1AxisPath":"result.$index.label","yAxisPath":"result.$index.metricValue"}},"responsive":true,"size":{"colspan":2,"rowspan":2},"type":"line"},"title":"Test-linkStatus","type":"exploration-line"}],"title":"Test-linkStatus","type":"exploration-line"},"displayOptions":[{"Metric":"hw.network.up_max","id":"hw-network-up_max-Max","yAxis":"left"}]}'

$Organization1 = Get-IntersightOrganizationOrganization -Moid "0599c48*****52d33672ec" | Get-IntersightMoMoRef

$mo1 = New-IntersightMetricsMetricsExploration -Granularity "PT10M" -Intervals @("last.day") -IsWidget $false -MetricCriteria @($MetricCriteria11) -Name "Test-linkStatus" -Organization $Organization1 -VisualConfig $VisualConfig1

Power Statistics:
$MetricCriteria11 = Initialize-IntersightMetricsMetricCriterion -Aggregation "" -Filters @() -Groups @() -Instrument "hw.power_supply" -IsEnabled $true -Metric "hw.power_min" -MetricAggregation "Min" -TopLimit 5
$VisualConfig1 = '{"chartType":"line","dashboardInstance":{"instanceId":"line:metricsExploration","notFilterable":true,"srcTypes":[{"customOptions":{"title":"Test_power_supply"},"instanceId":"line:metricsExploration","options":{"explorationModel":{"Granularity":"PT10M","Intervals":"last.day","MetricCriteria":[{"Aggregation":"","Filters":[],"Groups":[],"Instrument":"hw.power_supply","IsEnabled":true,"Metric":"hw.power_min","MetricAggregation":"Min","TopLimit":5,"TopSort":"Dsc"}],"Name":"","VisualConfig":{"chartType":"line","displayOptions":[{"Metric":"hw.power_min","id":"hw-power_min-Min","yAxis":"left"}]},"id":"2024-12-17T07:09:58.910Z"},"format":{"basedOnInterval":true},"granularity":"PT10M","interval":"last.day","legend":{"position":"bottom"},"mappings":{"xAxisPath":"timestamp","y":{"ids":["hw-power_min-Min"],"postfixLabelPath":"result.$index.postfixValue","scale":"linear","units":"W","y1AxisPath":"result.$index.label","yAxisPath":"result.$index.metricValue"}},"responsive":true,"size":{"colspan":2,"rowspan":2},"type":"line"},"title":"Test_power_supply","type":"exploration-line"}],"title":"Test_power_supply","type":"exploration-line"},"displayOptions":[{"Metric":"hw.power_min","id":"hw-power_min-Min","yAxis":"left"}]}'

$Organization1 = Get-IntersightOrganizationOrganization -Moid "0599c48*****52d33672ec" | Get-IntersightMoMoRef

$mo1 = New-IntersightMetricsMetricsExploration -Granularity "PT10M" -Intervals @("last.day") -IsWidget $false -MetricCriteria @($MetricCriteria11) -Name "Test_powerStatus" -Organization $Organization1 -VisualConfig $VisualConfig1

Memory Statistics:
$MetricCriteria11 = Initialize-IntersightMetricsMetricCriterion -Aggregation "" -Filters @() -Groups @() -Instrument "hw.memory" -IsEnabled $true -Metric "hw.status_max" -MetricAggregation "Max" -TopLimit 5
$VisualConfig1 = '{"chartType":"table","dashboardInstance":{"instanceId":"table:metricsExploration","srcTypes":[{"customOptions":{"srcTypes":"metricsExploration","title":"Test-MemoryStatus"},"instanceId":"table:metricsExploration","options":{"columns":[{"dataPath":"timestamp","label":"dashboard.dashlet.timestamp","min-width":177,"renderer":"common.dateTime"},{"dataPath":"label","label":"dashboard.dashlet.label","min-width":65,"renderer":"metrics.label"},{"dataPath":"metricValue","label":"dashboard.dashlet.metricValue","min-width":109,"renderer":"metrics.value","type":"float","uiFilterType":"number"},{"dataPath":"units","label":"an.metrics.visualEngine.units","max-width":300,"min-width":109},{"dataPath":"endpoint_count","label":"ucs.metrics.endpoints","min-width":100}],"explorationModel":{"Granularity":"PT10M","Intervals":"last.day","MetricCriteria":[{"Aggregation":"","Filters":[],"Groups":[],"Instrument":"hw.memory","IsEnabled":true,"Metric":"hw.status_max","MetricAggregation":"Max","TopLimit":5,"TopSort":"Dsc"}],"Name":"","VisualConfig":{"chartType":"table","displayOptions":[{"Metric":"hw.status_max","id":"hw-status_max-Max","yAxis":"left"}]},"id":"2024-12-17T13:09:27.809Z"},"size":{"colspan":1,"rowspan":2}},"title":"Test-MemoryStatus","type":"exploration-table"}],"title":"Test-MemoryStatus","type":"exploration-table"},"displayOptions":[{"Metric":"hw.status_max","id":"hw-status_max-Max","yAxis":"left"}]}'

$Organization1 = Get-IntersightOrganizationOrganization -Moid "0599c48*****52d33672ec" | Get-IntersightMoMoRef

$mo1 = New-IntersightMetricsMetricsExploration -Granularity "PT10M" -Intervals @("last.day") -IsWidget $false -MetricCriteria @($MetricCriteria11) -Name "Test-MemoryStatus" -Organization $Organization1 -VisualConfig $VisualConfig1

Filtering and Sorting:
To narrow down your results, you can add specific filters or order your results using the Filters property in the Initialize-IntersightMetricsMetricCriterion cmdlet and the TopSort property.

@MarkMorsing
Copy link
Author

Hello @jingiris05 Thanks for your reply

I still can't find any results for the actual metrics in these? This spawns an exploration, but how do i actually retrieve the results?

@jingiris05
Copy link

Hello @MarkMorsing,
You can refer to the example in the following link to retrieve the results: https://github.com/CiscoDevNet/intersight-powershell-utils/blob/main/monitoring-examples/README.md
Please review the example and modify it as per your requirements to retrieve the desired results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants