StatisticsCollector 정책

<ph type="x-smartling-placeholder"></ph> 현재 Apigee Edge 문서를 보고 있습니다.
Apigee X 문서.
정보

대상

메시지 내 데이터(예: 제품 ID, 가격, REST 등)에 대한 통계를 수집할 수 있습니다. 액션, 클라이언트 및 타겟 URL, 메시지 길이 등이 포함됩니다. 데이터는 흐름 변수에서 가져올 수 있음 Apigee에서 사전 정의된 변수입니다.

통계 데이터는 분석 서버로 전달되어 보고서를 생성합니다. Edge 관리 UI 또는 Edge API를 사용하여 보고서를 볼 수 있습니다.

샘플

기본 예시

<StatisticsCollector name="publishPurchaseDetails">
  <Statistics>
    <Statistic name="productID" ref="product.id" type="string">999999</Statistic>
    <Statistic name="price" ref="product.price" type="string">0</Statistic>
  </Statistics>
</StatisticsCollector>

이 예에서는 두 가지 맞춤 변수에 대한 통계 정보를 수집합니다. product.idproduct.price 모든 요청에서 통계 수집기 정책은 이 두 변수의 값을 애널리틱스에 기록합니다. 있습니다.

또한 이 예에서는 각 변수에 선택적 기본값을 설정합니다. 여기서 기본값은 product.id의 값이 999999임 및 기본 product.price에 는 0입니다. 변수가 정의되지 않고 기본값을 지정하지 않으면 데이터가 기록되어야 합니다. 기본값을 지정하는 경우 기본값은 로 확장됩니다.

통계 데이터를 수집한 후 에지 관리 UI 또는 API를 사용할 수 있습니다. 통계를 가져옵니다. 통계를 가져올 때는 변수를 productID로 표시 가격을 각각 입력합니다.

통계 액세스

이 예시에서는 Edge Management API를 사용하여 productID 컬렉션입니다. 이 요청은 각 제품 ID에 대해 제출된 메시지 수의 합계에 기반한 제품 ID 있습니다. {org_name} 변수를 조직 이름으로 바꿉니다. 계정의 이메일과 비밀번호를 email:password

데이터가 이전된 시간 간격을 포함하도록 timeRange 매개변수를 설정합니다. 수집됩니다. 기본적으로 현재 날짜로부터 6개월 이상 지난 데이터에는 액세스할 수 없습니다. 만약 6개월이 지난 데이터에 액세스하려면 Apigee Edge 지원팀에 문의하세요.

$ curl https://api.enterprise.apigee.com/v1/o/{org_name}/environments/test/stats/productID?"select=sum(message_count)&timeRange=1/19/2015%2000:00~6/21/2015%2000:00&timeUnit=day"
-u email:password

응답에서 name 필드에는 제품 ID가 포함되고 값은 각 날짜의 요청 수를 보여줍니다.

{
  "environments" : [ {
    "dimensions" : [ {
      "metrics" : [ {
        "name" : "sum(message_count)",
        "values" : [ {
          "timestamp" : 1353369600000,
          "value" : "4.0"
        } ]
      } ],
      "name" : "52"
    }, {
      "metrics" : [ {
        "name" : "sum(message_count)",
        "values" : [ {
          "timestamp" : 1353369600000,
          "value" : "19.0"
        } ]
      } ],
      "name" : "14"
    }, ...
  } ],
  "metaData" : {
    "samplingRate" : "100"
  }
}

수집을 위해 데이터 추출

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="GetWeatherData">
    <VariablePrefix>weather</VariablePrefix>
    <XMLPayload>
       <Namespaces>
          <Namespace prefix="yweather">http://xml.weather.yahoo.com/ns/rss/1.0</Namespace>
       </Namespaces>
       <Variable name="location" type="string">
          <XPath>/rss/channel/yweather:location/@city</XPath>
       </Variable>
       <Variable name="condition" type="string">
          <XPath>/rss/channel/item/yweather:condition/@text</XPath>
       </Variable>
    </XMLPayload>
</ExtractVariables>

통계 수집기 정책에 따라 수집된 데이터는 변수에 저장해야 합니다. 이러한 변수는 Apigee에서 사전 정의하거나 커스텀 변수로 정의할 수 있습니다.

이 예시에서는 변수 추출 정책을 사용하여 XML 페이로드에서 데이터를 추출합니다. 날씨 정보가 포함된 광고 소재입니다. 정책은 다음과 같은 역할을 합니다.

  • 도시 이름을 추출하여 weather.location이라는 변수에 씁니다.
  • 현재 조건을 추출하여 weather.condition이라는 변수에 씁니다.

그런 다음 통계 수집기 정책을 사용하여 변수를 사용할 수 있습니다.

<StatisticsCollector name="publishPurchaseDetails">
  <Statistics>
    <Statistic name="weatherLocation" ref="weather.location" type="string"></Statistic>
    <Statistic name="weatherCondition" ref="weather.condition" type="string"></Statistic>
  </Statistics>
</StatisticsCollector>

에서 XML 페이로드에서 데이터를 추출하는 방법을 보여주는 전체 가이드는 통계 수집기 정책은 API 분석 참고 메시지 콘텐츠 사용


통계 수집기 정책 정보

통계 수집기 정책이 실행되면 하나 이상의 현재 값을 기록합니다. 변수로 사용할 수 있습니다. 이러한 변수는 Apigee에서 사전 정의된 흐름 변수이거나 정의할 수 있습니다 이 데이터는 에지 분석 서버에 작성됩니다.

정책에서 수집한 통계 데이터에 액세스하려면 Edge API 또는 Edge를 사용하세요. 관리 UI를 제공합니다. 예를 들어 에지 관리 UI를 사용하여 수집된 데이터를 다양한 형식으로 보여줍니다.

통계 수집기 정책을 사용하는 자세한 튜토리얼은 Analyze API를 참조하세요. 메시지 콘텐츠 사용

정책 입력 위치

통계 수집기 정책을 API의 요청 또는 응답 흐름에 배치할 수 있습니다. 사용할 수 있습니다 하지만 여러 Statistics Collector 정책을 프록시에 두는 경우 실행할 데이터는 애널리틱스 서버에 작성된 데이터와 이전 통계 수집기 정책이 손실됩니다.

API 프록시에 여러 Statistics Collector 정책이 있을 수 있는 시나리오는 각각이 요청 또는 응답 흐름에 있고 다른 하나는 오류 핸들러에 있을 때. 결함이 있는 경우 발생한 경우 오류 핸들러의 통계 수집기가 수집됩니다. 통계 수집기를 사용하여 오류에 대한 정보를 기록하거나 필요한 다른 모든 정보를 기록합니다. 오류의 통계 수집기 통계 수집기인지 여부에 관계없이 수집된 데이터를 결정합니다. 알 수 있습니다.

자세한 내용은 오류 처리를 참조하세요.

요소 참조

요소 참조는 통계 수집기의 요소 및 속성을 설명합니다. 정책

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<StatisticsCollector async="false" continueOnError="false" enabled="true" name="Statistics-Collector-1">
    <DisplayName>Statistics Collector 1</DisplayName>
    <Statistics>
        <Statistic name="statName" ref="varName" type="refDataType">defaultStatValue</Statistic>
    </Statistics>
</StatisticsCollector>
드림

&lt;StatisticsCollector&gt; 속성

<StatisticsCollector async="false" continueOnError="false" enabled="true" name="Stats-1">

The following table describes attributes that are common to all policy parent elements:

Attribute Description Default Presence
name

The internal name of the policy. The value of the name attribute can contain letters, numbers, spaces, hyphens, underscores, and periods. This value cannot exceed 255 characters.

Optionally, use the <DisplayName> element to label the policy in the management UI proxy editor with a different, natural-language name.

N/A Required
continueOnError

Set to false to return an error when a policy fails. This is expected behavior for most policies.

Set to true to have flow execution continue even after a policy fails.

false Optional
enabled

Set to true to enforce the policy.

Set to false to turn off the policy. The policy will not be enforced even if it remains attached to a flow.

true Optional
async

This attribute is deprecated.

false Deprecated

<DisplayName> element

Use in addition to the name attribute to label the policy in the management UI proxy editor with a different, natural-language name.

<DisplayName>Policy Display Name</DisplayName>
Default

N/A

If you omit this element, the value of the policy's name attribute is used.

Presence Optional
Type String

&lt;Statistics&gt;/&lt;Statistic&gt; 요소

<Statistics>
    <Statistic name="statName" ref="varName" type="refDataType">defaultStatValue</Statistic>
</Statistics>
속성 설명 기본값 접속 상태
이름

지정된 변수에 대해 수집된 데이터를 참조하는 데 사용되는 이름입니다. 시청 시 애널리틱스 데이터의 경우 이 이름을 사용하여 변수에 대해 수집된 데이터를 참조합니다. ref로 지정 속성의 값을 제공합니다.

ref로 지정된 변수가 요청에서 정의되지 않았거나 포함된 경우 defaultStatValue는 수집됩니다. 기본값을 생략하면 변수로 사용됩니다.

이름 지정 제한사항

커스텀 분석 변수에는 다음과 같은 이름 지정 제한이 적용됩니다.

해당 사항 없음 필수
ref

통계를 수집하는 흐름 변수입니다. 이 변수는 Apigee에서 사전 정의된 변수 또는 API 프록시에서 정의한 커스텀 변수입니다.

참조 속성은 주로 변수 추출에서 정의한 맞춤 변수를 참조합니다. 정책 자세한 내용은 변수 추출 정책을 참조하세요.

해당 사항 없음 필수
유형

ref 속성으로 지정된 변수의 데이터 유형을 지정합니다. 유효한 값은 다음과 같습니다. string/integer/float/long/double/boolean.

문자열 유형 데이터의 경우 맞춤 보고서입니다. 숫자 데이터 유형 (integer/float/long/double)의 경우 다음을 참조하세요. 맞춤 보고서의 통계 데이터로서 측정기준 또는 측정항목으로 제공됩니다. 자세한 내용은 맞춤 보고서 관리하기를 참고하세요.

type의 값 ref가 사전 정의된 Apigee 흐름 변수 또는 유형이 추출 변수의 XML 페이로드에서 선언되었습니다. 정책

문자열 선택사항

오류 참조

This section describes the error messages and flow variables that are set when this policy triggers an error. This information is important to know if you are developing fault rules for a proxy. To learn more, see What you need to know about policy errors and Handling faults.

Runtime errors

None.

Deployment errors

Error name Cause Fix
UnsupportedDatatype If the type of the variable specified by the ref attribute in the <Statistic> element of the Statistics Collector policy is unsupported, then the deployment of the API proxy fails. The supported data types are string, integer, float, long, double, and boolean.
InvalidName If the name used to reference the data collected for the specified variable defined within the <Statistic> element of the Statistics Collector policy conflicts with a system-defined variable, then the deployment of the API proxy fails. Some of the known system-defined variables are organization and environment.
DatatypeMissing If the type of the variable specified by the ref attribute in the <Statistic> element of the Statistics Collector policy is missing, then the deployment of the API proxy fails.

Fault variables

None.

스키마

각 정책 유형은 XML 스키마(.xsd)로 정의됩니다. 참고로 GitHub에서 정책 스키마를 사용할 수 있습니다.

관련 주제

자세한 내용은 다음을 참고하세요.