Perform search (Stream)

post

/serviceapi/querylanguage.export

Perform a search by using the ExportRequest object. The only mandatory body parameter is queryString. To learn more about how queries work, see Get Started With Log Analytics.

This API will output the query results as a stream as they become available.

Request

Supported Media Types
Header Parameters
Body ()
Query to be exported
Root Schema : ExportRequest
Type: object
Show Source
  • Default Value: false
    Include columns in response
    Example: true
  • Default Value: false
    Localize results, including header columns, LOV and timestamp values.
  • Maximum number of results retrieved from data source. Note a maximum value will be enforced; if the export results can be streamed, the maximum will be 50000000, otherwise 10000; that is, if not streamed, actualMaxTotalCountUsed = Math.min(maxTotalCount, 10000). Export will incrementally stream results depending on the queryString. Some commands including head/tail are not compatible with streaming result delivery and therefore enforce a reduced limit on overall maxtotalcount. no sort command or sort by id, e.g. ' | sort id ' - is streaming compatible sort by time and id, e.g. ' | sort -time, id ' - is streaming compatible all other cases, e.g. ' | sort -time, id, mtgtguid ' - is not streaming compatible due to the additional sort field
    Example: 500
  • Allowed Values: [ "csv" ]
    Specifies the format for the returned results. Possible values include: csv (comma delimited).
    Example: csv
  • Query to perform. To learn more about how queries work, see Get Started With Log Analytics.
    Example: * | stats count by 'Log Source'
  • Amount of time, in seconds, allowed for a query to complete. If this time expires before the query is complete, any partial results will be returned.
  • Allowed Values: [ "LOG", "SECURITY" ]
    Each subsystem has its own namespace for fields it contains. This means two fields in different subsystems can have the same name; for example, log.status and target.status refer to two different fields. The subsystem parameter identifies the default subsystem to use when validating/querying a field that is not explicity qualifed by its subsystem.
  • TargetFilters
  • TimeFilter
    Discriminator: type
Nested Schema : TargetFilters
Type: object
Show Source
Nested Schema : TimeFilter
Type: object
Discriminator: type
Nested Schema : filters
Type: array
Show Source
Nested Schema : TargetFilter
Type: object
Show Source
Nested Schema : values
Type: array
Show Source
Back to Top

Response

Supported Media Types

200 Response

Operation succeeded
Body ()
Root Schema : OutputStream
Type: object

400 Response

Bad request. See response body for explanation.
Body ()
Root Schema : InternalErrorResponse
Type: object
Show Source
Nested Schema : messages
Type: array
Show Source
Nested Schema : violations
Type: array
Show Source
Nested Schema : ParserViolation
Type: object
Show Source

403 Response

Forbidden. User does not have required privileges.

500 Response

Internal server error. See response body for explanation.
Body ()
Root Schema : InternalErrorResponse
Type: object
Show Source
Nested Schema : messages
Type: array
Show Source
Nested Schema : violations
Type: array
Show Source
Nested Schema : ParserViolation
Type: object
Show Source
Back to Top

Examples

This cURL call will return all logs for all Database Instance and Cluster Database targets whose name contains the substring TEST:

  1. Create a new JSON file called testQuery.json and copy the following:
    {
      "queryString": "'target type' in ('Database Instance', 'Cluster Database') target like '%TEST%' | fields target, 'target type', message"
  2. Run the following cURL command:
    curl -u "OMC_USERNAME" -X POST -H "Content-Type:application/json" "https://"OMC_URL"/serviceapi/querylanguage/{version}/export" -d "@testQuery.json"

Example of Response

The following shows an example of the response body.

{
  "columns":[{"name":"target", "displayName":"Target", "valueType":"string", ...},
    {"name":"target_type", "displayName":"Target Type", "valueType":"string", ...},
    {"name":"msg", "displayName":"Msg", "valueType":"string", ...}],
  "results":[["TEST_DB1", "oracle_database", "msg1"],
    ["TEST_DB2", "oracle_database", "msg2"],
    ["TEST_RAC1", "rac_database", "msg3"],
   ...]
}
Back to Top