AFAnalysisService.QueryRuntimeInformation Method (String, String)
- Last UpdatedNov 18, 2025
- 4 minute read
- PI System
- AF SDK 2024 R2
- Developer
This method queries fields of analyses from PI Analysis Service for this PISystem.
Namespace: OSIsoft.AF.Analysis
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
public IEnumerable<IList<AFAnalysisServiceRuntimeFieldValue>> QueryRuntimeInformation( string queryString, string fields )
Public Function QueryRuntimeInformation ( queryString As String, fields As String ) As IEnumerable(Of IList(Of AFAnalysisServiceRuntimeFieldValue)) Dim instance As AFAnalysisService Dim queryString As String Dim fields As String Dim returnValue As IEnumerable(Of IList(Of AFAnalysisServiceRuntimeFieldValue)) returnValue = instance.QueryRuntimeInformation(queryString, fields)
public: IEnumerable<IList<AFAnalysisServiceRuntimeFieldValue^>^>^ QueryRuntimeInformation( String^ queryString, String^ fields )
member QueryRuntimeInformation : queryString : string * fields : string -> IEnumerable<IList<AFAnalysisServiceRuntimeFieldValue>>
Parameters
- queryString
- Type: SystemString
Query string to filter the results. - fields
- Type: SystemString
Expected fields to be returned.
Return Value
Type: IEnumerableIListAFAnalysisServiceRuntimeFieldValueValue lists of AFAnalysisServiceRuntimeFieldValue objects corresponding to the specified fields.
Exceptions
| Exception | Condition |
|---|---|
| InvalidOperationException | This exception is thrown when connection to the analysis service fails for any reason. |
| ArgumentNullException | This exception is thrown when fields is . |
Remarks
This method queries analyses runtime status from PI Analysis Service. The operation takes a query string and expected field names. The results are returned as IListT objects.
| Only information about the analyses that you have Read security right is returned. |
The argument queryString can be used to filter analyses by the supported fields from RuntimeInformationFields. The query language syntax is similar to that of AFSearch with the following notable differences:
- All the search conditions are implicitly AND. The AND keyword itself is not supported in the syntax.
- An empty string always matches an empty string, even for the Name filter.
- IN operator is supported only for strings.
- Contextually invalid comparisons such as "Name := 10" always default to FALSE, rather than throwing an exception.
- Time-stamps must be specified as strings.
- Ordering and limiting the number of responses are all part of the queryString syntax. The following fields can be used: sortyBy, sortOrder, and maxCount.
The argument fields is used to specify the requested fields as a space-separated list. At least one field must be specified. For supported field names, see RuntimeInformationFields.
| When analysis has not evaluated, runtime fields such as lastLag, lastElapsed, etc. will return the default values. |
Examples
Below are some example queries:
- name := 'Analysis*'
- path := '*Database1*Element1*Analysis*'
- lastTriggerTime :< '*-1m'
- status :in ('Running', 'Warning')
- lastEvaluationStatusDetail := 'Error' lastLag :> 10000
// Retrieve query results as ordered fields IEnumerable<IList<AFAnalysisService.RuntimeFieldValue>> results = analysisService.QueryRuntimeInformation("path: '*Database1*Steam*' status :in ('Running', 'Error') sortBy: 'lastLag' sortOrder: 'Desc'", "id name status lastLag lastTriggerTime"); if (!results.Any()) return; // First result var first = results.First(); Guid guid = (Guid)first[0]; Guid guid_alternative = first[0].ToObject<Guid>(); string name = first[1]; double lastLag = (double)first[3]; AFTime lastTrigger = (AFTime)first[4];