REST API 基本フィルター
最終更新日 - 25年2025月XNUMX日
LogicMonitor REST API を使用して API 呼び出しを行うと、結果が多すぎる場合があります。 検索をより具体的にするために、API フィルターを使用できます。 パターンを使用できますフィルターを作成します。
このサポート記事では、REST API を使用しました /alert/alerts と/device/devices フィルターの使用方法を説明する例として。 次の演算子でサポートされている値でエンドポイントをフィルタリングできます。
| Operator | 詳細説明 |
| : | 等しい |
| !: | 等しくない |
| > | 越える |
| < | 以下 |
| >: | 以上 |
| <: | 以下 |
| ~ | 含む |
| !~ | 含まれていません |
管理者の役割を持つユーザーは、非管理者の役割を持つユーザーよりも多くの結果を受け取ります。 管理者の役割を持つユーザーは、より多くの権限を持ち、ほとんどのデバイスにアクセスできます。 一方、管理者以外の役割を持つユーザーは、アクセスできるデバイスに基づいて結果を取得します。
特殊文字のエンコード
API v3 リクエストで文字列フィルターを使用する場合は、正確な結果を確保するために、フィルター値を XNUMX 回 URL エンコードする必要があります。
フィルタ文字列に括弧などの特殊文字が含まれている場合 ( の三脚と )エンコードする前に括弧をエスケープする必要があります。次の例をご覧ください。
デバイスをフィルタリングするには displayName abc-(test)-1特殊文字をエスケープするには、複数のエンコード手順を実行する必要があります。
- バックスラッシュ(
\):abc-\(test\)-1 - エスケープされた文字を URL エンコードします。
- 交換する
\(%5C%28 - 交換する
\)%5C%29
結果の文字列:abc-%5C%28test%5C%29-1
- 交換する
- 値を二重に URL エンコードします。
- 交換する
%5C%28%255C%2528 - 交換する
%5C%29%255C%2529
最終的にエンコードされた文字列:abc-%255C%2528test%255C%2529-1
- 交換する
API v3 リクエストでフィルターを適用するには、次の形式を使用します。
{{url}}/device/devices?filter=displayname:"abc-%255C%2528test%255C%2529-1"一般的な例
このセクションでは、任意の REST API エンドポイントについて次の例を参照できます。
注意: これらは単なるサンプルであり、ビジネス要件に合わせて変更する必要があります。
- 色が赤のリソースをフィルタ
filter=color:"red"- 名前が * のリソースをフィルター処理する
aaaそしてステータスはactive
filter=name:"*aaa",status:"active"- ステータスが
activeorsuspend
filter=status:"active"|"suspend"- 連絡先オブジェクトの名前が であるリソースをフィルター処理します
hoo
filter=contact.name:"hoo"- プロパティ配列に次の名前の要素が少なくとも XNUMX つあるリソースをフィルター処理します。
location
filter=properties.name:"location"- ステータスが
suspendまたは名前はaaaorbbborccc
filter=name:"aaa"|"bbb"|"ccc"||status:"suspend"- キーワードを含むすべてのリソースを検索します
filter=_all~"keyword"フィルター /alert/alerts APIエンドポイント
フィルタを使用する場合は、次の点を考慮する必要があります。
- パラメーターに基づいてエンドポイントをフィルタリングすると、複数回 API をヒットしても、アラート数に変更 (アラートの新規追加または削除) がない限り、結果は一貫します。
Sort リクエスト属性を指定すると、結果は alert プロパティに従ってソートされます。 たとえば、アラートが startEpoch アラート プロパティに基づいて並べ替えられている場合、結果はアラートの startEpoch に従って並べ替えられます。 一部のアラートの startEpoch が等しい場合、結果はアラート ID プロパティの昇順に基づいてソートされます。 したがって、結果は常に一貫しています。 - GET アラート リスト API のエンドポイントをフィルタリングできます (
/alert/alerts)。 GET アラート リスト API の応答は、要求パラメーター (フィルター) を使用してフィルター処理できます。 - AND 演算子のみを使用して、アラート プロパティとその値をフィルター処理できます。 たとえば、フィルター= 、 、…条件がどこにあるか
- フィルタリングできます
/alert/alerts一度に複数のプロパティを持つエンドポイント。 例えば、
リクエストURL
{{url}}/alert/alerts?offset=0&size=300&sort=startEpoch&filter=startEpoch>:1653295431,startEpoch<:1658146793,severity:"4"|"3",cleared:"*",resourceTemplateName:"Host status",monitorObjectName~"pod-kube"ここでは、XNUMX つのフィルターがアラート プロパティに適用されます。 startEpoch, severity, cleared, resourceTemplateName, monitorObjectName.
startEpochis1653295431 <= startEpoch <= 1658146793severityどちらでもかまいません3or4cleared値は true または false ですresourceTemplateName等しいHost statusmonitorObjectName含まれていますpod-kube
応答本文では、このクエリはフィルターに従って結果を一覧表示します。
{
"total": -301,
"items": [
{
"resourceId": 12596234,
"anomaly": false,
"instanceName": "HostStatus",
"monitorObjectId": 775798,
"endEpoch": 1653295561,
"rule": "",
"threshold": "> 300 300 300",
"type": "dataSourceAlert",
"startEpoch": 1653295431,
"enableAnomalyAlertGeneration": "",
"internalId": "LMD50170983",
"ackComment": "",
"monitorObjectName": "kube-proxy-mj7w2-pod-kube-system-dashboard-test",
"dataPointName": "idleInterval",
"instanceId": 284641854,
"dataPointId": 99721,
"suppressDesc": null,
"nextRecipient": 0,
"suppressor": null,
"id": "DS101384979",
"ruleId": 0,
"alertValue": "395.0",
"adAlert": false,
"ackedBy": "",
"severity": 4,
"sdted": false,
"ackedEpoch": 0,
"chain": "",
"SDT": null,
"subChainId": 0,
"enableAnomalyAlertSuppression": "",
"receivedList": "",
"monitorObjectType": "device",
"acked": false,
"resourceTemplateType": "DS",
"clearValue": "44.0",
"instanceDescription": "",
"dependencyRoutingState": null,
"monitorObjectGroups": [],
"dependencyRole": null,
"chainId": 0,
"resourceTemplateId": 143475810,
"cleared": true,
"adAlertDesc": "",
"resourceTemplateName": "Host Status"
},
{
"resourceId": 12596120,
"anomaly": false,
"instanceName": "HostStatus",
"monitorObjectId": 775797,
"endEpoch": 1653295561,
"rule": "",
"threshold": "> 300 300 300",
"type": "dataSourceAlert",
"startEpoch": 1653295431,
"enableAnomalyAlertGeneration": "",
"internalId": "LMD50170864",
"ackComment": "",
"monitorObjectName": "coredns-78fcd69978-snnq2-pod-kube-system-dashboard-test",
"dataPointName": "idleInterval",
"instanceId": 284641831,
"dataPointId": 99721,
"suppressDesc": null,
"nextRecipient": 0,
"suppressor": null,
"id": "DS101384981",
"ruleId": 0,
"alertValue": "396.0",
"adAlert": false,
"ackedBy": "",
"severity": 4,
"sdted": false,
"ackedEpoch": 0,
"chain": "",
"SDT": null,
"subChainId": 0,
"enableAnomalyAlertSuppression": "",
"receivedList": "",
"monitorObjectType": "device",
"acked": false,
"resourceTemplateType": "DS",
"clearValue": "4.0",
"instanceDescription": "",
"dependencyRoutingState": null,
"monitorObjectGroups": [],
"dependencyRole": null,
"chainId": 0,
"resourceTemplateId": 143475810,
"cleared": true,
"adAlertDesc": "",
"resourceTemplateName": "Host Status"
}
],
"searchId": "",
"isMin": false
}例: /alert/alerts filter
- エポック範囲 1653295431 <= の間に生成されたアラートをフィルター処理します
startEpoch<= 1663756550
{{url}}/alert/alerts?filter=startEpoch>:1653295431,startEpoch<:1663756550- でアラートをフィルタリングする
severity= 3 または 4。重大度 3 はエラーを示し、重大度 4 は重大なアラートを示します。
{{url}}/alert/alerts?filter=severity:"4"|"3"- 以下を含むすべてのアラートを表示します
clearedの三脚とunclearedアラート
{{url}}/alert/alerts?filter=cleared:"*"- フィルター
clearedアラート
{{url}}/alert/alerts?filter=cleared:true- でアラートをフィルタリングする
resourceTemplateName=Host status
{{url}}/alert/alerts?filter=resourceTemplateName:"Host status"- でアラートをフィルタリングする
monitorObjectName含むpod-kube
{{url}}/alert/alerts?filter=monitorObjectName~"pod-kube"- 5 つのアラート プロパティを使用してアラートをフィルター処理する –
startEpoch,severity,cleared,resourceTemplateName,monitorObjectName. 結果は startEpoch (昇順) に基づいて並べ替えられます。 オフセットが 0 で、指定されたサイズが 300 であるため、フィルター処理されたすべてのアラートのうち、最初の 300 個のアラートが取得されます。
{{url}}/alert/alerts?offset=0&size=300&sort=startEpoch&filter=startEpoch>:1653295431,startEpoch<:1658146793,severity:"4"|"3",cleared:"*",resourceTemplateName:"Host status",monitorObjectName~"pod-kube"- 次のタイプのアラートをフィルタ
dataSourceAlertそして認められる
{{url}}/alert/alerts?filter=acked:true,type:"dataSourceAlert"- エスカレーション チェーンが
Secondaryおよびアラート ルール名に含まれるCritical
{{url}}/alert/alerts?filter=chain:"Secondary",rule~"Critical"- アラートのフィルタ
instanceNameisHostStatus
{{url}}/alert/alerts?filter=instanceName:"HostStatus"- アラートのフィルタ
dataPointNameisLatency
{{url}}/alert/alerts?filter=dataPointName:"Latency"- SDT にあるアラートをフィルター処理する
{{url}}/alert/alerts?filter=sdted:true- 次のアラートをフィルタ
clearedそして、していますendEpoch<= 1658820186
{{url}}/alert/alerts?filter=cleared:true,endEpoch<:1658820186- 次のアラートをフィルタ
clearedそして、していますendEpoch> 1658820186
{{url}}/alert/alerts?filter=cleared:true,endEpoch>1658820186- 次のアラートをフィルタ
clearedそして、していますendEpoch<=1658820186 およびendEpoch> = 1658820079
{{url}}/alert/alerts?filter=cleared:true,endEpoch<:1658820186,endEpoch>:1658820079/ のフィルターdevice/devices APIエンドポイント
次のフィルターを使用して、API 呼び出しを絞り込むことができます。
- ID が 44 のデバイスをフィルタ
{{url}}/device/devices?filter=id:44- 文字列で終わる名前のデバイスをフィルタリングする
service,devicetypeis6
{{url}}/device/devices?filter=name:"*service",deviceType:6- でデバイスをフィルタリングする
hostGroupIds24517or31
{{url}}/device/devices?filter=hostGroupIds:"24517" | "31"- でデバイスをフィルタリングする
inheritedPropertiesプロパティ名の XNUMX つがsnmp.community資産価値に関係なく。
{{url}}/device/devices?filter=inheritedProperties.name:"snmp.community"- 次のデバイスをフィルタ
displayName文字列が含まれていますMemberまたはデバイスid>11. 結果には、XNUMX つまたは両方のフィルターに一致するデバイスが表示されます。
{{url}}/device/devices?filter=displayName~"*Member" || id>11- 次のデバイスをフィルタ
displayName文字列が含まれていますMemberAND デバイスid> 11. 結果には、両方のフィルターに一致するデバイスのみが表示されます。
{{url}}/device/devices?filter=displayName~"*Member", id>11- キーワードを含むすべてのデバイスを検索します
new device
{{url}}/device/devices?filter=_all~"new device"演算子の例
含むおよび含まない (~ および !~) 演算子
次のクエリを実行します。
{{url}}/device/devices?fields=autoProperties,name,id&filter=autoProperties.name:"predef.externalResourceID",autoProperties.value~"service"応答本文で、このクエリは、デバイスの ID、名前、および autoProperties を一覧表示します。 autoProperties.name = predef.externalResourceID または任意の autoProperties.value 部分文字列 = service.
注意: また、特殊文字または数字のみを含む autoProperty 値もリストします。
{
"total":4865,
"items":[
{
"id":44,
"name":"Instance",
"autoProperties":[
{
"name":"predef.externalResourceID",
"value":"service_44"
},
{
"name":"predef.externalResourceType",
"value":"Service"
}
]
},
{
"id":63,
"name":"gcp",
"autoProperties":[
{
"name":"predef.externalResourceID",
"value":"service_63"
},
{
"name":"predef.externalResourceType",
"value":"Service"
}
]
},
{
"id":65,
"name":"cloudAndNormal",
"autoProperties":[
{
"name":"predef.externalResourceID",
"value":"service_memberdevice_65"
},
{
"name":"predef.externalResourceType",
"value":"ServiceMember"
}
]
{
"id": 2378,
"name": "1.1.1.3",
"autoProperties": [
{
"name": "predef.externalResourceID",
"value": "service_2378"
},
{
"name": "predef.externalResourceType",
"value": "Service"
},
{
"name": "auto.host",
"value": "1.1.1.3"
}
]
},
}等しい、含む、より大きい、より小さい (:、~、>、<) 演算子
次のクエリを実行します。
{{url}}/device/devices?filter=id<5000,displayName~"service",hostGroupIds:"1",createdOn>1559000000応答本文で、このクエリは ID が 5000 未満のすべてのデバイスを一覧表示します AND displayName 「を含む」service" ストリング、 hostGroupIds =「1」、および createdOn 時間 > 1559000000
{
"total": 1,
"items": [
{
"id": 4389,
"name": "czservice",
"displayName": "czservice",
"deviceType": 6,
"relatedDeviceId": -1,
"currentCollectorId": -4,
"preferredCollectorId": -4,
"autoBalancedCollectorGroupId": 0,
"preferredCollectorGroupId": 1,
"preferredCollectorGroupName": "@default",
"description": "",
"createdOn": 1559236150,
"updatedOn": 1632927244,
"disableAlerting": false,
"autoPropsAssignedOn": 0,
"autoPropsUpdatedOn": 0,
"scanConfigId": 0,
"link": "",
"enableNetflow": false,
"netflowCollectorId": 0,
"netflowCollectorGroupId": 0,
"netflowCollectorGroupName": null,
"isPreferredLogCollectorConfigured": false,
"currentLogCollectorId": 0,
"logCollectorId": 0,
"logCollectorDescription": null,
"logCollectorGroupId": 0,
"logCollectorGroupName": null,
"lastDataTime": 0,
"lastRawdataTime": 0,
"hostGroupIds": "1",
"sdtStatus": "none-none-none",
"userPermission": "write",
"rolePrivileges": [],
"hostStatus": "normal",
"alertStatus": "none",
"alertStatusPriority": 100000,
"awsState": 1,
"azureState": 1,
"gcpState": 1,
"alertDisableStatus": "none-none-none",
"alertingDisabledOn": null,
"collectorDescription": "Service Data Aggregator",
"netflowCollectorDescription": null,
"customProperties": [
{
"name": "predef.bizservice.evalMembersInterval",
"value": "30"
},
{
"name": "predef.bizservice.members",
"value": "{\"device\":[{\"deviceGroupFullPath\":\"Devices by Type*\",\"deviceDisplayName\":\"127.0.0.34_PhysicalDatastore\",\"deviceProperties\":[]}],\"instance\":[]}"
},
{
"name": "system.categories",
"value": ""
}
],
"resourceIds": null,
"upTimeInSeconds": 0,
"deletedTimeInMs": 0,
"toDeleteTimeInMs": 0,
"hasDisabledSubResource": false,
"ancestorHasDisabledLogicModule": false,
"systemProperties": [
{
"name": "system.enablenetflow",
"value": "false"
},
{
"name": "system.collectorplatform",
"value": "n/a"
},
{
"name": "system.collectorid",
"value": "-4"
},
{
"name": "system.deviceId",
"value": "4389"
},
{
"name": "system.prefcollectordesc",
"value": "Service Data Aggregator"
},
{
"name": "system.collectordesc",
"value": "Service Data Aggregator"
},
{
"name": "system.deviceGroupId",
"value": "1"
},
{
"name": "system.resourceCreatedOn",
"value": "1559236150"
},
{
"name": "system.devicetype",
"value": "6"
},
{
"name": "system.collectorversion",
"value": "0"
},
{
"name": "system.prefcollectorid",
"value": "-4"
},
{
"name": "system.displayname",
"value": "czservice"
},
{
"name": "system.hostname",
"value": "czservice"
}
],
"autoProperties": [
{
"name": "predef.externalResourceID",
"value": "service_4389"
},
{
"name": "predef.externalResourceType",
"value": "Service"
}
],
"inheritedProperties": [
{
"name": "test.pass",
"value": "********"
},
{
"name": "esx.user",
"value": "n n "
},
{
"name": "snmp.community",
"value": "********"
},
{
"name": "esx.pass",
"value": "********"
},
{
"name": "ssh.pass",
"value": "********"
}
],
"syntheticsCollectorIds": null
}
],
"searchId": null,
"isMin": false
}