Flex setup to call Windows PowerShell

Hi, trying to setup Flex integration to monitor windows terminal server sessions. This is my first Flex integration but I have reviewed lots of examples and documentation but can’t figure out the issue.

I setup yml file and cycled the infrastructure agent.
Yml file:


  • name: nri-flex # We’re telling the Infra agent to run Flex!
    interval: 60s
    timeout: 45s
    config: # Flex configuration starts here!
    name: TS
    - event_type: TS_Sessions
    - run: “query user|convertto-json”
    shell: powershell
    I see data but error “Exit status 1” with “error exec” set to the run command. The command is running as I see output but the command output is in the “Error Msg” column. My understanding is that I should see a field for each column of the output thus allowing me to query. I have tried calling a powershell script but can’t get any output from that.

Any assistance would be greatly appreciated.

1 Like

Hi @kfiedler1 ,

Welcome to the New Relic Community. I went ahead and created you a ticket and someone from our support team should be reaching out shortly.

hi @kfiedler1 ,

Thanks for reaching out!
Firstly I would recommend to increase the timeout value.
I would recommend increasing the timeout in the configuration file until you stop seeing that error appear. Once it stops appearing, check to see if the data is coming through correctly, or if you’re seeing new errors in the logs.

You could also try to run this command which will manually run the flex integration, which prevents the output from being mixed up in the regular logs. Once you’ve run the command, please send us the output file for review.

./nri-flex -verbose -config_file [/path/to/nri-flex/configFile.yaml] > [/output/to/file.log]

Please refer to:


i have increased the timeout up to 300s and the error still persists. Here is the output of the nri-flex debug command:

C:\Program Files\New Relic\newrelic-infra\newrelic-integrations>nri-flex -verbose -pretty -config_file “C:\Program Files\New Relic\newrelic-infra\integrations.d\flex-TS-config.yml”
time=“2022-01-06T08:43:56-06:00” level=debug msg=“Function.isAvailable: enter”
time=“2022-01-06T08:43:56-06:00” level=debug msg=“Function.isAvailable: exit status: false”
time=“2022-01-06T08:43:56-06:00” level=info msg=com.newrelic.nri-flex GOARCH=amd64 GOOS=windows version=1.4.3
time=“2022-01-06T08:43:56-06:00” level=debug msg=“config: git sync configuration not set”
time=“2022-01-06T08:43:56-06:00” level=warning msg=“config: testing agent config, agent features will not be available”
time=“2022-01-06T08:43:56-06:00” level=debug msg=“config: running async” name=TS
time=“2022-01-06T08:43:56-06:00” level=debug msg=“config: processing apis” apis=1 name=TS
time=“2022-01-06T08:43:56-06:00” level=debug msg=“fetch: collect data” name=TS
time=“2022-01-06T08:43:56-06:00” level=debug msg=“commands: executing” count=1 name=TS
time=“2022-01-06T08:43:56-06:00” level=debug msg=“command: failed” context_err= err=“exit status 1” exec=“query user” suggestion=“if you are handling this error case, ignore”
time=“2022-01-06T08:43:56-06:00” level=debug msg=“processor-data: running data handler” name=TS
time=“2022-01-06T08:43:56-06:00” level=debug msg=“config: finished variable processing apis” apis=1 name=TS
time=“2022-01-06T08:43:56-06:00” level=info msg=“flex: completed processing configs” configs=1
“name”: “com.newrelic.nri-flex”,
“protocol_version”: “3”,
“integration_version”: “1.4.3”,
“data”: [
“metrics”: [
“context_error”: “”,
“error”: “exit status 1”,
“error_exec”: “query user”,
“error_msg”: " USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME\r\n\u003ekfiedler rdp-tcp#74 34 Active . 1/6/2022 7:54 AM\r\n",
“event_type”: “TS_Sessions”,
“integration_name”: “com.newrelic.nri-flex”,
“integration_version”: “1.4.3”
“event_type”: “flexStatusSample”,
“flex.Hostname”: “TS-PPE”,
“flex.IntegrationVersion”: “1.4.3”,
“flex.counter.ConfigsProcessed”: 1,
“flex.counter.EventCount”: 1,
“flex.counter.EventDropCount”: 0,
“flex.counter.TS_Sessions”: 1,
“flex.time.elaspedMs”: 58,
“flex.time.endMs”: 1641480236958,
“flex.time.startMs”: 1641480236900
“inventory”: {},
“events”: []

Hey there @kfiedler1,

I took a look at the configuration layout that you sent over, as well as the output of running the integration manually, and I’m thinking I see the issue. Based on the output:

“error_msg”: " USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME\r\n\u003ekfiedler rdp-tcp#74 34 Active . 1/6/2022 7:54 AM\r\n",

it appears that the command query user is being executed, but the returned information isn’t associated with any parsing rules in the flex config. Because of this, the integration is attempting to ingest the returned information (looks like line-1 headers?) without any form of formatting, and is being bounced because of it.

I would recommend looking at this documentation on our GitHub: https://github.com/newrelic/nri-flex/blob/master/docs/basic-tutorial.md#3-your-first-flex-integration. If you scroll down a bit, you’ll see a section that details the different parsing config options, such as split: horizontal, split_by, row_start, etc. My assumption is that once the integration knows how to break down the various headers and information being sent to it, you’ll see the error mentioned above disappear.

If you’re interested in how these various parameters can be used, I would recommend checking out our Examples folder in the nri-flex repository located here: https://github.com/newrelic/nri-flex/tree/master/examples. The examples inside the various script will provide some context on how the integration breaks down the data fed to it.

Hope this helps!


Excellent question and answers

Hello all

Seems like the issues are being solved? can you please confirm it is all and if there is anything else we can help you with?