What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Limit Channel Generation for Dynamic REST Custom Sensor

Votes:

0

Hi There,

I have a REST Custom Sensor that has been configured to dynamically create channels from an API. Is there a way to filter or limit the values from the API that does not exceed the 50 channel limitation?

Any help would be greatly appreciated.

Thanks, Jodan Tran

api custom rest

Created on Feb 18, 2019 7:30:07 AM



4 Replies

Votes:

0

Unfortunately, there's no way to filter the channels, other than via the JSON path. The following thread has some nice examples:

https://stackoverflow.com/questions/29703891/jsonpath-and-operator-on-array

The Rest Sensor also supports && and ||, so you could give that one a shot :)


PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team

Created on Feb 18, 2019 9:02:29 AM by  Stephan Linke [Paessler Support]

Last change on Feb 18, 2019 9:02:41 AM by  Stephan Linke [Paessler Support]



Votes:

0

I have a similar situation, trying to filter from a generic channel created to avoid hundreds of channels and only filtering through projects that are of interest. I'm trying to use JSON path, however haven't been able to get the filter to work properly.

REST API Response:

{
    "executionTime": {
        "millis": 176,
        "seconds": 0
    },
    "returnCode": 0,
    "root": [
        {
            "active": "true",
            "addStatisticsCodeEnabled": "false",
            "applicationBundleName": null,
            "applicationFeatureURL": null,
            "applicationGroup": null,
            "applicationId": "_etKaMNi2EeiDS5lpQcx7fA",
            "applicationName": "Corrected_TestContextVar",
            "applicationType": "JOB",
            "applicationVersion": "0.3",
            "applyContextToChildren": "false",
            "artifactGroupId": "org.example.testcontextvariable.job",
            "artifactId": "Corrected_TestContextVar",
            "artifactVersion": "0.4.0-LATEST",
            "awaitingExecutions": "0",
            "branch": "trunk",
            "commandLineVersion": "7.0.1.20180411_1414",
            "concurrentExecution": "false",
            "contextName": "DEV",
            "description": null,
            "errorStatus": "NO_ERROR",
            "execStatisticsEnabled": "false",
            "executionServerId": "JOB_SERVER_3",
            "featuresName": null,
            "featuresVersion": "0.4.0-LATEST",
            "framework": "",
            "frozenExecutions": "0",
            "id": "32",
            "idQuartzJob": "32",
            "jobServerLabelHost": "qav1-tj1",
            "jobscriptarchivefilename": "1540772209274_task_32.zip",
            "label": "asdf",
            "lastDeploymentDate": "2018-10-28 20:17:05.0",
            "lastEndedRunDate": "2018-10-28 20:17:12.0",
            "lastRunDate": "2018-10-28 20:17:10.0",
            "lastScriptGenerationDate": "2018-10-28 08:56:54.0",
            "lastTaskTraceError": "",
            "latestVersion": "false",
            "log4jLevel": "Info",
            "nextFireDate": null,
            "onUnknownStateJob": "WAIT",
            "onlineStatus": null,
            "originType": "ZIP",
            "pid": null,
            "processingState": "false",
            "projectId": "10",
            "projectName": "TESTCONTEXTVARIABLE",
            "regenerateJobOnChange": "false",
            "remaingTimeForNextFire": null,
            "repositoryName": "qa_releases",
            "runAsUser": null,
            "snapshot": "false",
            "status": "READY_TO_RUN",
            "svnConnectionAvailable": null,
            "svnRevision": null,
            "taskType": "ARTIFACT_TASK",
            "timeOut": null,
            "triggersStatus": "NO_TRIGGER",
            "uniqueId": "bcd301d8-cdd2-43c1-b020-1be08f884b51",
            "virtualServerLabel": null
        },
        {
            "active": "true",
            "addStatisticsCodeEnabled": "true",
            "applicationBundleName": null,
            "applicationFeatureURL": null,
            "applicationGroup": null,
            "applicationId": "_etKaMNi2EeiDS5lpQcx7fA",
            "applicationName": "Corrected_TestContextVar",
            "applicationType": "JOB",
            "applicationVersion": "0.3",
            "applyContextToChildren": "false",
            "artifactGroupId": "org.example.testcontextvariable.job",
            "artifactId": "Corrected_TestContextVar",
            "artifactVersion": "0.4.6-LATEST",
            "awaitingExecutions": "0",
            "branch": "trunk",
            "commandLineVersion": "7.0.1.20180411_1414",
            "concurrentExecution": "false",
            "contextName": "QA",
            "description": "Testing with different context variables",
            "errorStatus": "NO_ERROR",
            "execStatisticsEnabled": "false",
            "executionServerId": "JOB_SERVER_3",
            "featuresName": null,
            "featuresVersion": "0.4.6-LATEST",
            "framework": "",
            "frozenExecutions": "0",
            "id": "33",
            "idQuartzJob": "33",
            "jobServerLabelHost": "qav1-tj1",
            "jobscriptarchivefilename": "1540785329196_task_33.zip",
            "label": "Context Variable Testing",
            "lastDeploymentDate": "2018-10-28 23:55:31.0",
            "lastEndedRunDate": "2018-10-28 23:55:32.0",
            "lastRunDate": "2018-10-28 23:55:31.0",
            "lastScriptGenerationDate": "2018-10-29 00:09:28.0",
            "lastTaskTraceError": "",
            "latestVersion": "false",
            "log4jLevel": "Info",
            "nextFireDate": null,
            "onUnknownStateJob": "WAIT",
            "onlineStatus": null,
            "originType": "ZIP",
            "pid": null,
            "processingState": "false",
            "projectId": "10",
            "projectName": "TESTCONTEXTVARIABLE",
            "regenerateJobOnChange": "false",
            "remaingTimeForNextFire": null,
            "repositoryName": "qa_releases",
            "runAsUser": null,
            "snapshot": "false",
            "status": "READY_TO_RUN",
            "svnConnectionAvailable": null,
            "svnRevision": null,
            "taskType": "ARTIFACT_TASK",
            "timeOut": "3600",
            "triggersStatus": "NO_TRIGGER",
            "uniqueId": "fb6798f6-6129-42c1-b641-c616d3d30e85",
            "virtualServerLabel": null
        }
]
}

This is my Generic Channel creation that works:

{
  "prtg": {
    "result": [
      {
        "value": {
			"["+ #1 +"]" + " Error Status": $..({@.label : lookup(@.errorStatus, "KILLED")}).*	
		}
      }
    ]
  }
}

This is the filter I'm trying to create and haven't had success yet:

{
  "prtg": {
    "result": [
      {
        "value": {
			"["+ #1 +"]" + " Error Status": $.[[email protected]=="TESTCONTEXTVARIABLE"].({@.label : lookup(@.errorStatus, "KILLED","JOB_ERROR","NO_ERROR")}).*	
		}
      }
    ]
  }
}

Error Message:

Parsing error: { "prtg": { "result": [ { "value": { "["+ #1 +"]" + " Error Status": $.[[email protected]=="TESTCONTEXTVARIABLE"].({@.label : lookup(@.errorStatus, "KILLED","JOB_ERROR","NO_ERROR")}).* } } ] } } }:6:38 - 6:39 unexpected "[" while scanning JSON select expected Ident, "." or "*".

Any ideas on how to get this filter to work? Also, is there anyway to have wildcards in the filters or regular expressions? Looking for something similar to: projectName LIKE *Core*Ingestion Which would match: "projectName": "nCore_Job_Ingestion" "projectName": "tCore_restore_Ingestion"

Thanks Gui Lopes

Created on Feb 18, 2019 11:54:17 AM



Votes:

1

I've forwarded the case to the developer, maybe he has an idea on how to get it to work :)

Created on Feb 18, 2019 7:37:20 PM by  Stephan Linke [Paessler Support]



Votes:

0

You might want to try the following (counting critical channels): "critical": len($[*][@.size > 10000 && @.active])

However, creating channels as soon as a limit is exceed may lead to unforseen (read untested) behavior. As this example is quite complex, you might want to check it out with PowerShell or Python and parse it with that one. Using the EXE/Script Advanced Sensors, you're not limited to the fifty channels of the sensor.

Created on Feb 19, 2019 1:47:48 PM by  Stephan Linke [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.