evtctxcnt()

Returns the number of event contexts currently existing for a specified topic. Use this function to determine the count of event contexts created by the evtctx command.

Syntax

evtctxcnt(TOPIC)

Parameters

TOPIC
The topic name for which to query the event context count. String. If null is specified, the total count of event contexts across all topics is returned.

Description

Returns the number of event contexts for the given TOPIC as a 32-bit integer.

If TOPIC is null, the function returns the total count of event contexts across all topics.

If there are no event contexts for the specified topic, 0 is returned.

Error codes

Error codeDescription
invalid-evtctxcnt-argumentsThe number of arguments is not 1.

Usage examples

  1. Query the current number of event contexts in the login_fail topic

    evtctx topic=login_fail key=src_user max_count=5
    | eval ctx_count = evtctxcnt("login_fail")
    
  2. Pass null as the topic argument to query the total number of event contexts across all topics

    evtctx topic=login_fail key=src_user
    | eval total = evtctxcnt(null)
    
  3. Query a topic that has no event contexts

    evtctx topic=login_fail key=src_user
    | eval cnt = evtctxcnt("no_such_topic")
    | # cnt: 0
    

Compatibility

evtctxcnt() has been available since before Sonar 4.0.