NR-Flex - How to get going with it. Simple steps and use case shared

Hello,
Its been a while since I have contributed to the forum, but happy to see all the amazing activity and changes that New relic has been making. One of the recent most features I and my team played around was NR-Flex ( https://blog.newrelic.com/product-news/how-to-use-new-relic-flex/ , https://docs.newrelic.com/docs/integrations/host-integrations/host-integrations-list/flex-integration-tool-build-your-own-integration)
I won’t go into the details of what is already documented but while reading and going through the GitHub we had to ensure we were understanding things well and I will now provide few things that can speed up your adoption of this feature.
NR-Flex gives you the power to ingest data you want with simple steps. This Ingestion than gives you the power to visualize the data and make it into a meaning full output like charts or alerts.

Here is how we went about taking a jump start to monitor the contents of a folder.

  1. Had to read the complete page to know more about NR-flex. ( you can skip that if you jump to https://github.com/newrelic/nri-flex/blob/master/docs/basic-tutorial.md) The page is useful.
  2. If you know you are going to play with windows or Linux ( Our case was windows) you can jump to https://github.com/newrelic/nri-flex/tree/master/examples/windows. Here you can find an example that you can copy to the integration folder of your New Relic infra deployment.
  3. Once the New Relic service is running and sending data to New Relic. You can query the NR DB.
    you will need to do select on the API name in the config. for example, if you are using winuptime PowerShell example from the about link. the API name Is WinUptime. so do a select * from WinUptimeSample.

So the Problems we had to solve:

  1. We want to monitor content in a folder and if the content is .failed generate an alert.
  2. Monitor important services running as windows service.

Solutions

  1. For this we use PowerShell script to find the data in the folder and send the data to New relic.
    # Use forward slashes on Windows paths as Flex handles these more gracefully

    This script will lookup the json file which tells New Relic to work on the folder “C:/homefolder/standalone/deployments/”

    From there I use PowerShell to recursively lookup files in the directory that have .failed

    Used to look up the Jboss directory

    integrations:

    • name: nri-flex
      config:
      name: warsmonitortest
      lookup_file: “C:/Program Files/New Relic/newrelic-infra/integrations.d/flex-warsmonitor.json”
      apis:
      - name: IsWarsDeplyed
      shell: powershell
      commands:
      - run: “Get-ChildItem -Path “${lf:directory}” -File ${lf:recursive} | Select-Object -Property Name | ConvertTo-Json”

    Json file
    [

    {

    "directory" : "C:/homefolder/standalone/deployments" ,

    "recursive" : "-Recurse"

    }

    ]

SELECT count(*) FROM IsWarsDeplyedSample where Name Like ‘%failed’ OR Name NOT LIKE ‘%deployed’ and Name NOT LIKE ‘%war’ and Name NOT LIKE ‘%txt’ and Name NOT LIKE ‘%ear’ and hostname = ‘test1’

# Command above is used in the new relic to filter a query for the information that we need.
  1. Monitor Service is a simple example available in the example folder of the above Github link.
    Let me know if you have any questions.

Hope this helps. Happy to answer questions if any.
thanks
Manas

4 Likes

Hey Manas :wave:t5: Appreciate you sharing this information about your team’s experience with NR-Flex. Nothing like getting firsthand knowledge to help other community members :star_struck:

1 Like

@MKhanna - Miss you! So nice to see you again! Super appreciate you coming back and sharing you know how with us! Hope all is well up there! :canada:

1 Like

@hross thank you for the warm gesture. yes, all well here. starting to get cold with covid still impacting life. And NR Community always has my support. will try to contribute more. Hope you are keeping safe.
thanks

2 Likes