Ana içeriğe geç

Manual ILM Policy and Template Creation

Warning

If log management will be done through Apinizer, these operations do not need to be performed, these operations are done automatically by Apinizer.

Variables​

Dynamic values and their descriptions in the requests are shown in the table below.

VariableDescription
<ELASTICSEARCH_IP_ADDRESS>Host information of the Elasticsearch cluster.
<ELASTICSEARCH_PORT>Port information of the Elasticsearch cluster.
<INDEX_KEY>Unique identifier for the index.
<INDEX_PATTERN_NAME>Index pattern name. It is the index name followed by * (e.g.: apinizer-log-apiproxy-default*).
<ILM_POLICY_NAME>ILM policy name (e.g.: apinizer-log-ilm-policy-default).
<NUMBER_OF_SHARDS>Number of shards for the index (Apinizer default: 1).
<NUMBER_OF_REPLICAS>Number of replicas for the index (Apinizer default: 0).
<REFRESH_INTERVAL>Index refresh interval (Apinizer default: 5s).
<LOAD_FIXED_BITSET_FILTERS_EAGERLY>The index.load_fixed_bitset_filters_eagerly setting (Apinizer default: true).

Creating ILM Policies​

Creating ILM Policy Request Named apinizer-log-ilm-policy-default​

curl -XPUT "http://<ELASTICSEARCH_IP_ADDRESS>:<ELASTICSEARCH_PORT>/_ilm/policy/apinizer-log-ilm-policy-<INDEX_KEY>" \
-H 'Content-Type: application/json' \
--data-binary @- <<'EOF'
{
"policy": {
"phases": {
"hot": {
"min_age": "0ms",
"actions": {
"rollover": {
"max_age": "30d",
"max_size": "30gb",
"max_docs": 15000000
},
"set_priority": {
"priority": null
}
}
},
"warm": {
"actions": {
"readonly": {},
"allocate": {
"number_of_replicas": 0,
"include": {},
"exclude": {}
},
"shrink": {
"number_of_shards": 1
},
"forcemerge": {
"max_num_segments": 1
},
"set_priority": {
"priority": null
}
}
},
"cold": {
"min_age": "90d",
"actions": {
"set_priority": {
"priority": null
}
}
}
}
}
}
EOF

Creating Template​

Creating Template Request Named apinizer-log-apiproxy-template-default​

curl -X PUT "http://<ELASTICSEARCH_IP_ADDRESS>:<ELASTICSEARCH_PORT>/_index_template/apinizer-log-apiproxy-template-<INDEX_KEY>" \
-H 'Content-Type: application/json' \
--data-binary @- <<'EOF'
{
"index_patterns": ["<INDEX_PATTERN_NAME>"],
"data_stream": {},
"template": {
"settings": {
"index": {
"lifecycle": {
"name": "<ILM_POLICY_NAME>"
},
"number_of_shards": "<NUMBER_OF_SHARDS>",
"number_of_replicas": "<NUMBER_OF_REPLICAS>",
"refresh_interval": "<REFRESH_INTERVAL>",
"load_fixed_bitset_filters_eagerly": "<LOAD_FIXED_BITSET_FILTERS_EAGERLY>"
}
},
"mappings": {
"properties": {
"aprp": {
"type": "keyword"
},
"fcrb": {
"type": "text"
},
"hr1ru": {
"type": "keyword"
},
"aci": {
"type": "keyword"
},
"subi": {
"type": "keyword"
},
"subp": {
"type": "keyword"
},
"subpl": {
"type": "keyword"
},
"subo": {
"type": "keyword"
},
"ack": {
"type": "keyword"
},
"cot": {
"type": "keyword"
},
"coi": {
"type": "keyword"
},
"coo": {
"type": "keyword"
},
"usub": {
"type": "keyword",
"ignore_above": 256
},
"uids": {
"type": "keyword",
"ignore_above": 256
},
"ocid": {
"type": "keyword",
"ignore_above": 256
},
"mcprc": {
"type": "keyword"
},
"mcpap": {
"type": "keyword"
},
"tapt": {
"type": "integer"
},
"trqpt": {
"type": "integer"
},
"trspt": {
"type": "integer"
},
"hr1rp": {
"type": "keyword"
},
"uok": {
"ignore_above": 50,
"type": "keyword"
},
"sr2t": {
"type": "integer"
},
"fcrp": {
"type": "nested",
"properties": {
"k": {
"type": "keyword"
},
"v": {
"type": "keyword"
}
}
},
"api": {
"type": "keyword"
},
"appi": {
"type": "keyword"
},
"appin": {
"type": "keyword"
},
"fcrh": {
"type": "nested",
"properties": {
"k": {
"type": "keyword"
},
"v": {
"type": "keyword"
}
}
},
"apn": {
"type": "keyword"
},
"pet": {
"ignore_above": 75,
"type": "keyword"
},
"apr": {
"type": "short"
},
"tbah": {
"type": "nested",
"properties": {
"k": {
"type": "keyword"
},
"v": {
"type": "keyword"
}
}
},
"ei": {
"type": "keyword"
},
"apmi": {
"type": "keyword"
},
"hr1qs": {
"type": "keyword"
},
"tbap": {
"type": "nested",
"properties": {
"k": {
"type": "keyword"
},
"v": {
"type": "keyword"
}
}
},
"ra": {
"type": "keyword"
},
"et": {
"ignore_above": 75,
"type": "keyword"
},
"tba": {
"type": "text"
},
"hr1rh": {
"type": "keyword"
},
"trt": {
"type": "integer"
},
"rrc": {
"type": "integer"
},
"rfc": {
"type": "integer"
},
"icr": {
"type": "boolean"
},
"crs": {
"type": "keyword"
},
"mc": {
"type": "integer"
},
"msc": {
"type": "integer"
},
"mfc": {
"type": "integer"
},
"mtd": {
"type": "long"
},
"ma": {
"type": "keyword"
},
"sr1t": {
"type": "integer"
},
"hr1ra": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"loc": {
"type": "geo_point"
},
"xff": {
"type": "keyword"
},
"apmn": {
"type": "keyword"
},
"hr1hm": {
"ignore_above": 50,
"type": "keyword"
},
"rt": {
"ignore_above": 7,
"type": "keyword"
},
"hr1lp": {
"type": "keyword"
},
"hr1ln": {
"type": "keyword"
},
"hr1pi": {
"type": "keyword"
},
"sc": {
"type": "short"
},
"fbarh": {
"type": "nested",
"properties": {
"k": {
"type": "keyword"
},
"v": {
"type": "keyword"
}
}
},
"tcb": {
"type": "text"
},
"hr1rsi": {
"type": "keyword"
},
"tch": {
"type": "nested",
"properties": {
"k": {
"type": "keyword"
},
"v": {
"type": "keyword"
}
}
},
"eat": {
"type": "keyword"
},
"hr1r1u": {
"type": "keyword"
},
"hr1p": {
"type": "keyword"
},
"hr1s": {
"type": "keyword"
},
"fbarb": {
"type": "text"
},
"@timestamp": {
"format": "yyyy-MM-dd'T'HH:mm:ss.S'Z'||yyyy-MM-dd'T'HH:mm:ss.SS'Z'||yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
"type": "date"
},
"ch": {
"type": "boolean"
},
"hr1ce": {
"type": "keyword"
},
"hr1sp": {
"type": "keyword"
},
"hr1sn": {
"type": "keyword"
},
"hr1la": {
"type": "keyword"
},
"hr1ct": {
"ignore_above": 50,
"type": "keyword"
},
"pi": {
"type": "keyword"
},
"hr1cp": {
"type": "keyword"
},
"hr1cl": {
"type": "keyword"
},
"aip": {
"type": "keyword"
},
"aipid": {
"type": "keyword"
},
"aivs": {
"type": "keyword"
},
"aim": {
"type": "keyword"
},
"aiti": {
"type": "long"
},
"aito": {
"type": "long"
},
"aitc": {
"type": "long"
},
"aicm": {
"type": "long"
},
"aicim": {
"type": "long"
},
"aicom": {
"type": "long"
},
"aiccm": {
"type": "long"
},
"aittft": {
"type": "long"
},
"aitpot": {
"type": "long"
},
"ailat": {
"type": "long"
},
"aisch": {
"type": "boolean"
},
"aigh": {
"type": "keyword"
},
"aigc": {
"type": "keyword"
},
"aigv": {
"type": "keyword"
},
"aircl": {
"type": "keyword"
},
"aircs": {
"type": "keyword"
},
"aircms": {
"type": "long"
},
"aircti": {
"type": "long"
},
"aircto": {
"type": "long"
},
"airccm": {
"type": "long"
},
"aipd": {
"type": "boolean"
},
"aifr": {
"type": "keyword"
},
"aistr": {
"type": "boolean"
},
"aivk": {
"type": "keyword"
},
"aitid": {
"type": "keyword"
},
"aiff": {
"type": "keyword"
},
"aiqsc": {
"type": "integer"
},
"aiqao": {
"type": "boolean"
},
"aidt": {
"type": "keyword"
},
"aigtms": {
"type": "long"
},
"aiinf": {
"type": "long"
},
"aiovh": {
"type": "long"
},
"mcptn": {
"type": "keyword"
},
"mcpjrid": {
"type": "keyword"
},
"mcptno": {
"ignore_above": 256,
"type": "keyword"
},
"mcptco": {
"type": "integer"
},
"a2atk": {
"type": "keyword"
},
"a2act": {
"type": "keyword"
},
"a2ats": {
"type": "keyword"
},
"a2asno": {
"ignore_above": 256,
"type": "keyword"
},
"a2aaco": {
"type": "integer"
},
"afr": { "type": "keyword", "ignore_above": 256 },
"rfr": { "type": "keyword" },
"rco": { "type": "keyword" },
"rec": { "type": "keyword" },
"red": { "type": "keyword", "ignore_above": 256 },
"rdsel": { "type": "long" },
"rddns": { "type": "long" },
"rdtcp": { "type": "long" },
"rdtls": { "type": "long" },
"rdttfb": { "type": "long" },
"rdbrd": { "type": "long" },
"rdpw": { "type": "long" },
"usc": { "type": "short" },
"uip": { "type": "keyword" },
"crf": { "type": "boolean" },
"rtr": { "type": "boolean" },
"gw": { "type": "keyword" },
"pll": { "type": "short" },
"plp": { "type": "short" },
"pla": { "type": "short" },
"plm": { "type": "short" },
"cct": { "type": "integer" },
"crt": { "type": "integer" },
"ccrt": { "type": "integer" },
"cwms": { "type": "integer" },
"cr": { "type": "keyword" },
"cl": { "type": "keyword" },
"pxt": {
"type": "nested",
"properties": {
"o": { "type": "integer" },
"t": { "type": "keyword" },
"d": { "type": "integer" },
"f": { "type": "keyword", "ignore_above": 1 }
}
}
}
}
}
}
EOF

Template Data Structure Table​

Field NameData Stored in Field/DescriptionJava Mapping TypeElastic Search Mapping Type
@timestampTime StampInstantdate format: yyyy-MM-dd'T'HH:mm:ss.S'Z' yyyy-MM-dd'T'HH:mm:ss.SS'Z' yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
aciApinizer Correlation IDStringkeyword
eiEnvironment IDStringkeyword
piProject IDStringkeyword
appiApplication IDStringkeyword
appinApplication NameStringkeyword
apiAPI Proxy IDStringkeyword
apnAPI Proxy NameStringkeyword
eatAPI TypeEnumkeyword
aprpAPI Proxy Relative PathStringkeyword
apmiAPI Proxy Method IDStringkeyword
apmnAPI Proxy Method NameStringkeyword
xffX Forwarded ForStringkeyword
hr1raHTTP Request Remote AddressStringtext, keyword
hr1hmHTTP Request HTTP MethodStringkeyword ignore_above: 50
hr1ctHTTP Request Content TypeStringkeyword ignore_above: 50
hr1piHTTP Request Path InfoStringkeyword
uokUsername or KeyStringkeyword ignore_above: 50
ackAPI Client KeyStringkeyword
cotClient Owner TypeStringkeyword
coiClient Owner IdStringkeyword
cooClient Organization IdStringkeyword
hr1cpHTTP Request Context PathStringkeyword
hr1qsHTTP Request Query StringStringkeyword
hr1ruHTTP Request Remote UserStringkeyword
hr1rsiHTTP Request Requested SessionIDStringkeyword
hr1r1uHTTP Request Request URIStringkeyword
hr1ceHTTP Request Character EncodingStringkeyword
hr1clHTTP Request Content LengthStringkeyword
hr1pHTTP Request ProtocolStringkeyword
hr1sHTTP Request SchemeStringkeyword
hr1snHTTP Request Server NameStringkeyword
hr1spHTTP Request Server PortStringkeyword
locLocationGeoLocation{ Double lat, Double lon }geo_point
hr1rhHTTP Request Remote HostStringkeyword
hr1rpHTTP Request Remote PortStringkeyword
hr1lnHTTP Request Local NameStringkeyword
hr1laHTTP Request Local AddrStringkeyword
hr1lpHTTP Request Local PortStringkeyword
trqptTime Request Pipeline TotalIntegerinteger
trsptTime Response Pipeline TotalIntegerinteger
rrcRouting Retry CountIntegerinteger
rfcRouting Failover CountIntegerinteger
trtTime Routing TotalIntegerinteger
taptTime API Proxy TotalIntegerinteger
chCache HitBooleanboolean
sr1tSize Request TotalIntegerinteger
sr2tSize Response TotalIntegerinteger
scStatus Codeintshort
rtResult TypeEnumkeyword ignore_above: 7
etError TypeEnumkeyword ignore_above: 75
petParent Error TypeEnumkeyword ignore_above: 75
afrAuthentication Failure ReasonEnumkeyword ignore_above: 256
fcrpFrom Client Read Only ParameterMap<String,String>nested k: keyword v: keyword
fcrhFrom Client Read Only HeaderMap<String,String>nested k: keyword v: keyword
fcrbFrom Client Read Only BodyStringtext
tbapTo Backend API ParameterMap<String,String>nested k: keyword v: keyword
tbahTo Backend API HeaderMap<String,String>nested k: keyword v: keyword
tbaTo Backend API BodyStringtext
fbarhFrom Backend API Read Only HeaderMap<String,String>nested k: keyword v: keyword
fbarbFrom Backend API Read Only BodyStringtext
tchTo Client HeaderMap<String,String>nested k: keyword v: keyword
tcbTo Client BodyStringtext
pxtPolicy Execution Times (written only when the option is enabled on the log target)List<PolicyExecutionTiming>nested o: integer t: keyword d: integer f: keyword ignore_above: 1
usubStable user ID: the sub claim of an IdP token, or the client itself for a client_credentials tokenStringkeyword ignore_above: 256
uidsToken issuer (iss) of an IdP token; apinizer for a token issued by ApinizerStringkeyword ignore_above: 256
ocidOAuth client the token was issued to (azp, otherwise client_id)Stringkeyword ignore_above: 256
subiSubscription IDStringkeyword
subpSubscription product IDStringkeyword
subplSubscription plan IDStringkeyword
suboConsumer organization ID of the subscriptionStringkeyword
aprAPI Proxy RevisionIntegershort
raRouting AddressStringkeyword
icrWhether the request was routed as a canary requestBooleanboolean
crsCanary routing statusEnumkeyword
mcNumber of mirror requests sentIntegerinteger
mscNumber of successful mirror requestsIntegerinteger
mfcNumber of failed mirror requestsIntegerinteger
mtdTotal duration of the mirror requestsLonglong
maMirror addressesList<String>keyword
rfrRouting failure reasonStringkeyword
rcoConfidence of the failure reason (HIGH, MEDIUM, LOW)Stringkeyword
recException class nameStringkeyword
redSanitized and truncated exception messageStringkeyword ignore_above: 256
rdselUpstream selection time (ns)Longlong
rddnsDNS resolve time (ns)Longlong
rdtcpTCP connect time (ns)Longlong
rdtlsTLS handshake time (ns)Longlong
rdttfbTime to first byte (ns); -1 when there was no responseLonglong
rdbrdResponse body read time (ns)Longlong
rdpwTime spent waiting for a connection from the pool (ns)Longlong
uscRaw status code returned by the backend (separate from the status returned to the client)Shortshort
uipUpstream ip:port actually connected toStringkeyword
crfWhether a pooled connection was reusedBooleanboolean
rtrWhether the request reached a backend that respondedBooleanboolean
gwWorker pod/host that processed the requestStringkeyword
pllConnections leased in the poolShortshort
plpPending connection requests in the poolShortshort
plaAvailable connections in the poolShortshort
plmMaximum connections in the poolShortshort
cctConfigured connect timeout (ms)Integerinteger
crtConfigured read timeout (ms)Integerinteger
ccrtConfigured connection-request (pool lease) timeout (ms)Integerinteger
cwmsTime spent writing the response to the client (ms); -1 for streaming responsesIntegerinteger
mcptnName of the MCP tool called by the requestStringkeyword
mcpjridJSON-RPC correlation IDStringkeyword
mcprcOutcome class of a tools/call: OK, TOOL_ERROR, JSONRPC_ERROR, TRANSPORT, POLICY_REJECTStringkeyword
mcpapApproval state of a tools/call held for approvalStringkeyword
mcptnoDistinct names of the outbound MCP tools called during the request, comma-separated (cut at 256 characters, marked with ,…)Stringkeyword ignore_above: 256
mcptcoTotal number of outbound tool calls during the requestIntegerinteger
a2atkA2A task IDStringkeyword
a2actA2A context ID (multi-turn correlation)Stringkeyword
a2atsLatest A2A task state, for example COMPLETED or FAILEDStringkeyword
a2asnoDistinct names of the outbound agent skills called during the request, comma-separated (cut at 256 characters)Stringkeyword ignore_above: 256
a2aacoTotal number of outbound agent calls during the requestIntegerinteger
aipLLM provider type (for example openai, anthropic)Stringkeyword
aipidID of the LLM provider record that served the requestStringkeyword
aimModel nameStringkeyword
aidtDeployment type: CLOUD, ON_PREM, or OTHERStringkeyword
aitiPrompt (input) tokensLonglong
aitoCompletion (output) tokensLonglong
aitcCached prompt tokensLonglong
aicmCost in micro USD (cost × 1,000,000)Longlong
aicimInput token cost in micro USDLonglong
aicomOutput token cost in micro USDLonglong
aiccmCached token cost in micro USDLonglong
aittftTime to first token (ms)Longlong
aitpotAverage time per output token (ms)Longlong
ailatTotal latency (ms)Longlong
aigtmsTotal time of the guardrail stage (ms)Longlong
aiinfUpstream LLM HTTP latency (ms)Longlong
aiovhGateway overhead: total minus guardrail minus inference (ms)Longlong
aischWhether the semantic cache returned a hitBooleanboolean
aighGuard that was triggeredStringkeyword
aigcCategory of the triggered ruleStringkeyword
aigvVerdict of the external guardrail: SAFE, UNSAFE, TIMEOUT, ERROR, or SKIPStringkeyword
aipdWhether PII was detectedBooleanboolean
aifrFinish reason (stop, length, tool_use, content_filter)Stringkeyword
aistrWhether the response was streamedBooleanboolean
aivkIdentity of the authenticated caller (the principal, not a record ID)Stringkeyword
aitidAI trace record referenceStringkeyword
aiffPrimary provider that failed overStringkeyword
aiqscSoft-cap percentage that was crossed (for example 80)Integerinteger
aiqaoWhether an ALERT_ONLY overflow fired and the request proceededBooleanboolean
airclLabel returned by the route classifierStringkeyword
aircsRoute classifier outcome: MATCHED, NONE, UNKNOWN_LABEL, TIMEOUT, ERROR, TRUNCATED, BACKOFF, NO_PROVIDER, or NO_INPUTStringkeyword
aircmsRoute classifier call latency (ms)Longlong
airctiRoute classifier prompt tokensLonglong
airctoRoute classifier completion tokensLonglong
airccmRoute classifier cost in micro USD (not included in aicm)Longlong
aivsWhy the request continued without the vector layer (RAG, semantic cache, or Topic Guard)Stringkeyword
crPipeline position where the Log policy captured the record (FROM_CLIENT, TO_BACKEND, FROM_BACKEND, TO_CLIENT); written only in Log policy recordsEnumkeyword
clAssignment level of the Log policy (API_PROXY_GROUP, API_PROXY, API_PROXY_METHOD); written only in Log policy recordsEnumkeyword
Info

You can review the data example created in this data structure on the API Traffic Log Record Data Structure page.

Index Creation and Querying​

When creating indices or querying with data stream, requests are sent according to the value in the index_patterns metadata within the template.

Index Creation​

curl -XPOST "http://<ELASTICSEARCH_IP_ADDRESS>:<ELASTICSEARCH_PORT>/apinizer-log-apiproxy-<INDEX_KEY>/_doc" -H 'Content-Type: application/json' -d'{"@timestamp": "2023-05-31T11:40:36.376Z"}'

Running Query​

curl -XGET "http://<ELASTICSEARCH_IP_ADDRESS>:<ELASTICSEARCH_PORT>/apinizer-log-apiproxy-<INDEX_KEY>/_search" \
-H 'Content-Type: application/json' \
--data-binary @- <<'EOF'
{
"from": 0,
"size": 10,
"query": {
"bool": {
"filter": [
{
"range": {
"@timestamp": {
"from": "now-10m/m",
"to": "now/m",
"include_lower": true,
"include_upper": true
}
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
},
"sort": [
{
"@timestamp": {
"order": "desc"
}
}
]
}
EOF
Info

The templates on this page are for the API traffic log. The index templates for SIEM destinations are different. See Elasticsearch Index Templates for SIEM Destinations.