首页 > 解决方案 > 推送自定义指标时 NotAuthorizedOrNotFound

问题描述

当我尝试使用 Oracle Cloud CLI 将自定义指标推送到 Oracle Cloud Monitoring 服务时,我收到以下错误:

ServiceError:
{
    "code": "NotAuthorizedOrNotFound",
    "message": "Authorization failed or requested resource not found.",
    "opc-request-id": "request id",
    "status": 404
}

使用管理员帐户和使用具有监视权限的实例主体时会发生这种情况。

这是我推送到监控服务的 JSON:

[
    {
        "namespace": "myFirstNamespace",
        "compartmentId": "tenant id",
        "resourceGroup": "myFirstResourceGroup",
        "name": "successRate",
        "dimensions": {
            "resourceId": "ocid1.exampleresource.region1.phx.exampleuniqueID",
            "appName": "myAppA"
        },
        "metadata": {
            "unit": "percent",
            "displayName": "MyAppA Success Rate"
        },
        "datapoints": [
            {
                "timestamp": "2021-06-01T22:19:20Z",
                "value": 83.0
            }
        ]
    }
]

我正在使用的 CLI 命令是:

oci monitoring metric-data post --metric-data file://metric-data.json

标签: oracle-cloud-infrastructure

解决方案


OCI CLI 命令应该是:

oci monitoring metric-data post --metric-data file://metric-data.json --endpoint https://telemetry-ingestion.{{ region }}.oraclecloud.com

替换{{ region }}为您所在的地区。

--endpoint https://telemetry-ingestion.{{ region }}.oraclecloud.com需要添加参数。


推荐阅读