美文网首页
阿里云cli命令行工具,自定义上传数据

阿里云cli命令行工具,自定义上传数据

作者: OPS_Joy | 来源:发表于2020-09-25 11:48 被阅读0次

    1.安装阿里云cli工具,官网有两种安装方式直接使用安装包或者编译安装,推荐直接使用包
    下载地址 https://github.com/aliyun/aliyun-cli/releases?spm=a2c4g.11186623.2.15.57d6233ds29Fud

    [root@iZt4n3zjaww2fcvorl9yzkZ software]# tar -zxf aliyun-cli-linux-3.0.16-amd64.tgz
    [root@iZt4n3zjaww2fcvorl9yzkZ software]# ll -h
    total 44M
    -rwxrwxrwx 1 tommy users  30M May 24  2019 aliyun
    -rw-r--r-- 1 root  root  8.8M Jan 17 17:44 aliyun-cli-linux-3.0.16-amd64.tgz
    

    2.配置cli 注意AccessKey ID和AccessKey Secret,Region要选择自己服务器所在区域

    [root@iZt4n3zjaww2fcvorl9yzkZ software]# ./aliyun configure
    Configuring profile 'default' ...
    Aliyun Access Key ID [None]: <Your AccessKey ID>
    Aliyun Access Key Secret [None]: <Your AccessKey Secret>
    Default Region Id [None]: cn-hangzhou
    Default output format [json]: json
    Default Language [zh]: zh
    

    查看配置信息

    [root@iZt4n3zjaww2fcvorl9yzkZ software]# ./aliyun configure list
    Profile   | Credential         | Valid   | Region           | Language
    --------- | ------------------ | ------- | ---------------- | --------
    default   | AK:***             | Invalid |                  | en
     *        | AK:***C4a          | Valid   | ap-southeast-1   | zh
    

    测试命令行上传,可编写脚本,计划任务

     [root@iZt4n3zjaww2fcvorl9yzkZ software]# ./aliyun cms PutCustomMetric  --MetricList.1.MetricName ecphttps  --MetricList.1.Dimensions '{"ecphttps":"https_status"}' --MetricList.1.Type 0  --MetricList.1.Values '{"value":'0'}' --MetricList.1.GroupId "19749538"
    {
        "RequestId": "C47D7854-9756-4863-AE58-EA98D2F74973",
        "Message": "success",
        "Code": "200"
    }
    

    错误编码含义
    200 正常
    206 返回信息为“reach max time series num”,表示您的可以使用的时间序列配额已用完,需要购买更多配额或删除不再使用的时间序列。返回信息为“not allowed original value, please upgrade service”,表示您使用的是免费版,无法使用上报原始数据的功能。返回信息为“type is invalid” ,type参数错误,请检查是否传入了0或1以外的数值。
    400 客户端请求中的语法错误
    403 校验失败、限速、没有授权
    500 服务器内部错误
    关键字解释
    PutCustomMetric是阿里云接口固定格式
    MetricList.N.MetricName:监控项名称
    MetricList.N.Dimensions:维度指标值
    MetricList.N.Type:上报数据类型,0原始值,1聚合值
    MetricList.N.Values:上报的数据
    MetricList.N.GroupId:上报服务器所在区域或组ID【重要】如下图所示
    其他细节可参照阿里云官网:
    自定上传其他细节: https://help.aliyun.com/document_detail/63275.html?spm=a2c4g.11186623.2.17.14142d39zvlihL
    阿里云PutCustomMetric接口详情:https://help.aliyun.com/document_detail/115004.html?spm=a2c4g.11186623.4.5.57d6233d8ciaWz

    图片.png
    图片.png
    图片.png
    图片.png
    图片.png

    ``

    相关文章

      网友评论

          本文标题:阿里云cli命令行工具,自定义上传数据

          本文链接:https://www.haomeiwen.com/subject/iwoiyktx.html