Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Cloud Eye/ API Reference/ API V1/ Monitoring Data/ Querying Monitoring Data of a Metric

Querying Monitoring Data of a Metric

Updated on 2024-12-26 GMT+08:00

Function

This API is used to query the monitoring data of a specified metric at a specified granularity in a specified time range. You can specify the dimension of data to be queried.

Debugging

You can debug the API in API Explorer which supports automatic authentication. API Explorer can automatically generate and debug example SDK code.

URI

GET /V1.0/{project_id}/metric-data?namespace={namespace}&metric_name={metric_name}&dim.{i}=key,value&from={from}&to={to}&period={period}&filter={filter}

  • Parameter description
    Table 1 Parameter description

    Parameter

    Mandatory

    Description

    project_id

    Yes

    Specifies the project ID.

    For details about how to obtain the project ID, see Obtaining a Project ID.

    Table 2 Query parameter description

    Parameter

    Mandatory

    Type

    Description

    namespace

    Yes

    String

    Specifies the namespace of a service. For details, see Services Interconnected with Cloud Eye.

    The namespace must be in the service.item format and contain 3 to 32 characters. service and item each must start with a letter and contain only letters, digits, and underscores (_).

    metric_name

    Yes

    String

    Specifies the metric name. You can obtain the metric names of existing alarm rules by referring to Querying Metrics.

    from

    Yes

    String

    Specifies the start time of the query. The time is a UNIX timestamp and the unit is ms.

    Rollup aggregates the raw data generated within a period to the start time of the period. If from and to are within a period, the query result will be empty due to the rollup failure. Set from to at least one period earlier than the current time.

    Take the 5-minute period as an example. If it is 10:35 now, the raw data generated between 10:30 and 10:35 will be aggregated to 10:30. In this example, if period is 5 minutes, from should be 10:30.

    NOTE:

    Cloud Eye rounds up from based on the level of granularity required to perform the rollup.

    to

    Yes

    String

    Specifies the end time of the query.

    The time is a UNIX timestamp and the unit is ms.

    from must be earlier than to.

    period

    Yes

    Integer

    Specifies how often Cloud Eye aggregates data, which can be

    • 1: Cloud Eye performs no aggregation and displays raw data.
    • 300: Cloud Eye aggregates data every 5 minutes.
    • 1200: Cloud Eye aggregates data every 20 minutes.
    • 3600: Cloud Eye aggregates data every hour.
    • 14400: Cloud Eye aggregates data every 4 hours.
    • 86400: Cloud Eye aggregates data every 24 hours.

    filter

    Yes

    String

    Specifies the data rollup method, which can be

    • average: Cloud Eye calculates the average value of metric data within a rollup period.
    • max: Cloud Eye calculates the maximum value of metric data within a rollup period.
    • min: Cloud Eye calculates the minimum value of metric data within a rollup period.
    • sum: Cloud Eye calculates the sum of metric data within a rollup period.
    • variance: Cloud Eye calculates the variance value of metric data within a rollup period.
    NOTE:

    Rollup uses a rollup method to aggregate raw data generated within a specific period. Take the 5-minute period as an example. If it is 10:35 now, the raw data generated between 10:30 and 10:35 will be aggregated to 10:30.

    dim

    Yes

    String

    A maximum of three metric dimensions are supported, and the dimensions are numbered from zero in the dim.{i}=key,value format. key cannot exceed 32 characters and value cannot exceed 256 characters.

    The following dimensions are only examples. For details about whether multiple dimensions are supported, see the dimension description in the monitoring indicator description of each service.

    Single dimension: dim.0=instance_id,i-12345

    Multiple dimensions: dim.0=instance_id,i-12345&dim.1=instance_name,i-1234

    NOTE:
    • dimensions can be obtained from the response body by calling the API for Querying Metrics.
    • OBS metric data can be queried only when the related OBS APIs are called.
  • Example:

    Request example 1: View the CPU usage of ECS whose ID is 6f3c6f91-4b24-4e1b-b7d1-a94ac1cb011d from 2019-04-30 20:00:00 to 2019-04-30 22:00:00. The monitoring interval is 20 minutes.

    GET https://{Cloud Eye endpoint}/V1.0/{project_id}/metric-data?namespace=SYS.ECS&metric_name=cpu_util&dim.0=instance_id,6f3c6f91-4b24-4e1b-b7d1-a94ac1cb011d&from=1556625600000&to=1556632800000&period=1200&filter=min

Request

None

Response

  • Response parameters
    Table 3 Parameter description

    Parameter

    Type

    Description

    datapoints

    Array of objects

    Specifies the metric data list. For details, see Table 4.

    Since Cloud Eye rounds up from based on the level of granularity for data query, datapoints may contain more data points than expected.

    metric_name

    String

    Specifies the metric ID. For example, if the monitoring metric of an ECS is CPU usage, metric_name is cpu_util. For details, see Services Interconnected with Cloud Eye.

    Table 4 datapoints data structure description

    Parameter

    Type

    Description

    average

    Double

    Specifies the average value of metric data within a rollup period.

    max

    Double

    Specifies the maximum value of metric data within a rollup period.

    min

    Double

    Specifies the minimum value of metric data within a rollup period.

    sum

    Double

    Specifies the sum of metric data within a rollup period.

    variance

    Double

    Specifies the variance of metric data within a rollup period.

    timestamp

    Long

    Specifies when the metric is collected. It is a UNIX timestamp in milliseconds.

    unit

    String

    Specifies the metric unit.

  • Example response
    Example response 1: The dimension is SYS.ECS, and the average CPU usage of ECSs is displayed.
    {
        "datapoints": [
            {
                "average": 0.23, 
                "timestamp": 1442341200000, 
                "unit": "%"
            }
        ], 
        "metric_name": "cpu_util"
    }
    Example response 2: The dimension is SYS.ECS, and the sum CPU usage of ECSs is displayed.
    {
        "datapoints": [
            {
                "sum": 0.53, 
                "timestamp": 1442341200000, 
                "unit": "%"
            }
        ], 
        "metric_name": "cpu_util"
    }
    Example response 3: The dimension is SYS.ECS, and the maximum CPU usage of ECSs is displayed.
    {
        "datapoints": [
            {
                "max": 0.13, 
                "timestamp": 1442341200000, 
                "unit": "%"
            }
        ], 
        "metric_name": "cpu_util"
    }

Returned Values

  • Normal

    200

  • Abnormal

    Returned Value

    Description

    400 Bad Request

    Request error.

    401 Unauthorized

    The authentication information is not provided or is incorrect.

    403 Forbidden

    Access to the requested page is forbidden.

    408 Request Timeout

    The request timed out.

    429 Too Many Requests

    Concurrent requests are excessive.

    500 Internal Server Error

    Failed to complete the request because of an internal service error.

    503 Service Unavailable

    The service is currently unavailable.

Error Codes

See Error Codes.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback