创建计量策略

<p>计量策略是指在API调用方调用API 时,是否对此次调用进行计费的策略。</p> <p><span style="font-size:18px"><strong>背景信息</strong></span></p> <p>如果API的提供方需要根据API的调用次数对API的调用方进行收费,API网关可以提供调用次数(即计量)的统计数据。API网关默认按照以下策略判定每次的API调用是否参与计费,系统默认的计量策略:</p> <ul> <li>当后端服务响应状态码为5xx时,则本次调用需要参与计量;</li> <li>当后端服务响应状态码为4xx时,则本次调用不需要参与计量;</li> <li>当后端服务响应状态码为其他时,则本次调用需要参与计量;</li> </ul> <p>同时,用户可以根据业务的实际场景自定义计量策略,覆盖上述默认的计量策略,可参考<a href="https://pinganyun.com/ssr/help/middleware/APIGateway/Instance_Management.Publishing_API.Calculation_Policy.Calculation_Policy_Detail" target="_blank">添加计量策略项</a>。</p> <p><span style="font-size:18px"><strong>注意事项</strong></span></p> <p>1.&nbsp; 每个用户在每个地域下最多可创建100个计量策略。</p> <p>2.&nbsp; 一个计量策略可以绑定多个API,但同一环境中一个API只能被一个计量策略绑定。</p> <p>3.&nbsp; 计量策略与API是相互独立的,只有将计量策略绑定到指定的API后,计量策略才对指定的API生效,可参考<a href="https://pinganyun.com/ssr/help/middleware/APIGateway/Instance_Management.Publishing_API.Calculation_Policy.Bind_API" target="_blank">绑定API</a>。</p> <p><span style="font-size:18px"><strong>操作步骤</strong></span></p> <p>1.&nbsp; 登录<a href="https://pinganyun.com/console/apiGateway" target="_blank">API网关管理控制台</a>。</p> <p>2.&nbsp; 单击左侧导航栏<strong>开放</strong><strong>API</strong> &gt;<strong> </strong><strong>计量策略</strong>,进入<strong>计量策略</strong>页面。</p> <p>3.&nbsp; 选择目标地域。</p> <p>4.&nbsp; 单击页面右上角的<strong>创建</strong>,进入<strong>创建计量策略</strong>页面。</p> <p>5.&nbsp; 根据以下信息创建计量策略。</p> <table border="1" cellpadding="0" cellspacing="0"> <tbody> <tr> <td style="background-color:#ededed; vertical-align:top"> <p><strong>配置项</strong></p> </td> <td style="background-color:#ededed; vertical-align:top"> <p><strong>说明</strong></p> </td> </tr> <tr> <td style="vertical-align:top"> <p>策略名称</p> </td> <td style="vertical-align:top"> <p>计量策略的名称。</p> <p><!--[if gte mso 9]><xml> <o:OLEObject Type="Embed" ProgID="PBrush" ShapeID="_x0000_i1025" DrawAspect="Content" ObjectID="_1633953766"> </o:OLEObject> </xml><![endif]--><img src="https://pcp-portal-sca.obs-cn-shenzhen.pinganyun.com/pcp-portal-sca/20193010145708-1f631abc9e11.png" style="height:26px; margin:0px; width:65px" />:</p> <p>1.&nbsp; 计量策略的名称在当前主账户的每个地域下必须唯一。</p> <p>2.&nbsp; 计量策略名称的长度为2~50个字符。</p> <p>3.&nbsp; 可包含汉字、英文、下划线_、或数字。</p> <p>4.&nbsp; 需要以英文或汉字开始。</p> </td> </tr> <tr> <td style="vertical-align:top"> <p>策略类型</p> </td> <td style="vertical-align:top"> <p>计量策略的类型,目前支持:</p> <p>&bull;&nbsp;&nbsp; 计量</p> <p>&bull;&nbsp;&nbsp; 不计量</p> </td> </tr> <tr> <td style="vertical-align:top"> <p>描述</p> </td> <td style="vertical-align:top"> <p>计量策略的描述信息。</p> <p><!--[if gte mso 9]><xml> <o:OLEObject Type="Embed" ProgID="PBrush" ShapeID="_x0000_i1026" DrawAspect="Content" ObjectID="_1633953767"> </o:OLEObject> </xml><![endif]--><img src="https://pcp-portal-sca.obs-cn-shenzhen.pinganyun.com/pcp-portal-sca/20193010145708-1f631abc9e11.png" style="height:26px; margin:0px; width:65px" />:描述信息长度为1~200个字符。</p> </td> </tr> </tbody> </table> <p>6.&nbsp; 单击<strong>确认</strong>。</p> <p><span style="font-size:18px"><strong>执行结果</strong></span></p> <p><strong>方法一</strong></p> <p>在<strong>计量策略</strong>页面下方提示<strong>创建成功</strong>。</p> <p><strong>方法二</strong></p> <p>在<strong>计量策略</strong>页面的目标地域下,可看到刚刚创建的计量策略。</p> <p><img src="https://pcp-portal-sca.obs-cn-shenzhen.pinganyun.com/pcp-portal-sca/20193010145635-192a9f4e9164.png" style="height:118px; width:830px" /></p> <p><span style="font-size:18px"><strong>后续操作</strong></span></p> <p>在<strong>计量策略</strong>页面的目标地域下,单击目标计量策略的名称,进入<strong>计量策略详情</strong>页面,可查看计量策略的基本信息。</p> <p><img src="https://pcp-portal-sca.obs-cn-shenzhen.pinganyun.com/pcp-portal-sca/20193010145627-11c1038f936e.png" style="height:84px; width:830px" /></p>
以上内容是否解决了您的问题?
请补全提交信息!
咨询·建议

电话咨询

400-151-8800

邮件咨询

cloud@pingan.com

在线客服

工单支持

解决云产品相关技术问题