Git Product home page Git Product logo

nri-windows-event-logs's Introduction

Deprecation notice

Collection of event log channels is now part of core New Relic Infrastructure Agent: https://docs.newrelic.com/docs/logs/enable-log-management-new-relic/enable-log-monitoring-new-relic/forward-your-logs-using-infrastructure-agent#winlog

Windows Event Log Integration

  • Pipes Windows PowerShell Get-EventLog entries to Insights.
  • LogName configurable through Infrastructure definition and config files.

Disclaimer

New Relic has open-sourced this integration to enable monitoring of this technology. This integration is provided AS-IS WITHOUT WARRANTY OR SUPPORT, although you can report issues and contribute to this integration via GitHub. Support for this integration is available with an Expert Services subscription.

Instructions

  1. Copy .zip from Releases to host
  2. Unzip files
  3. Copy infra-windows-logs-config.yml to C:\Program Files\New Relic\newrelic-infra\integrations.d
  4. Copy the remaining files to C:\Program Files\New Relic\newrelic-infra\custom-integrations
    1. infra-windows-logs-definition.yml
    2. infra-windows-logs.bat
    3. infra-windows-logs.ps1
  5. Run: net stop newrelic-infra
  6. Run: net start newrelic-infra

Events are sent to the Windows Event Logs Event Type

screenshot

nri-windows-event-logs's People

Contributors

a-james-faria avatar csandels avatar sschwartzman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nri-windows-event-logs's Issues

allow port and customize event

I was able to push event logs to new relic from my test machine. Which port I need to open in firewall and how can I customize events?

Can we get a syntax example of how to set up eventid filters?

I see from the files that there is an an option to pass in a colon separated list of eventid's, but none of the examples show what that would look like on the yml files, would it just be like this?

name: com.newrelic.windows.eventlog
protocol_version: 1
description: On-Host Integration for Windows Event Logs

commands:
application:
command:
- .\infra-windows-logs.bat
- Application
- 1234:5678:9999
interval: 30

Windows Event Log Collection Issues

Hello,
I tried to collect event log of windowsOS using nri-windows-event-logs, but i have a problem. Can you help me?

Windows event logs are not collected in Insight, and I have rarely modified the configuration file.

Windows OS: Windows Server 2008 R2
NewRelic Infra Agent Version: 1.11.21

  • C:\Program Files\New Relic\newrelic-infra\integrations.d\infra-windows-logs-config.yml
integration_name: com.newrelic.windows.eventlog

instances:
  - name: eventlog-system
    command: system
  - name: eventlog-application
    command: application
  • C:\Program Files\New Relic\newrelic-infra\custom-integrations\infra-windows-logs.bat
@ECHO OFF
set logName=%1
set eventIds=%2

IF DEFINED eventIds (
    powershell.exe -ExecutionPolicy Bypass -file "C:\Program Files\New Relic\newrelic-infra\custom-integrations\infra-windows-logs.ps1" -LogName %logName% -EventIds %eventIds%
    powershell.exe -ExecutionPolicy Bypass -file "C:\Program Files\New Relic\newrelic-infra\custom-integrations\infra-windows-logs.ps1" -LogName %logName%
)
  • C:\Program Files\New Relic\newrelic-infra\custom-integrations\infra-windows-logs-definition.yml
name: com.newrelic.windows.eventlog
protocol_version: 1
description: On-Host Integration for Windows Event Logs

commands:
  application:
    command:
      - C:\Program Files\New Relic\newrelic-infra\custom-integrations\infra-windows-logs.bat
      - Application
    interval: 30
  system:
    command:
      - C:\Program Files\New Relic\newrelic-infra\custom-integrations\infra-windows-logs.bat
      - System
    interval: 30
  • C:\Program Files\New Relic\newrelic-infra\custom-integrations\infra-windows-logs.ps1
###
# The following command is required for testing:
#
#[System.Diagnostics.EventLog]::CreateEventSource("New Relic","Application")
###


###
# Parameters (a.k.a. Command Line Arguments)
# Usage: -LogName "LogName" -EventIds 4608:4609:4946
# -LogName      The name of the event log to gather events from.  Ex: System, Appication, etc. (Required)
# -EventIds     An optional, colon delimited, list of event ids to gather.
###

param (
    [string]$LogName=$(throw "-LogName is mandatory"),
    [string]$EventIds
)

###
# Logic to handle getting new log entries by saving current date to file
# to use as -After argument of Get-Date in next pull. On first run we use current date.
# On subsequent runs it will use last date written to file.
#
# Uses LogName param to create timestamp for each LogName
###

$LAST_PULL_TIMESTAMP_FILE = "./last-pull-timestamp-$LogName.txt"


###
# If timestamp file exists, use it; otherwise,
# set timestamp to 15 minutes ago to pull some data on
# first run.
###

if (Test-Path $LAST_PULL_TIMESTAMP_FILE -PathType Leaf) {

    $timestamp = Get-Content -Path $LAST_PULL_TIMESTAMP_FILE -Encoding String | Out-String
    $timestamp = [DateTime] $timestamp.ToString()

} else{

    $timestamp = (Get-Date).AddMinutes(-240)

}

###
# Write timestamp to file to pull on next run.
###
Set-Content -Path $LAST_PULL_TIMESTAMP_FILE -Value (Get-Date -Format o)

###
# Pull events using -After param with timestamp
###
$events = Get-EventLog -LogName $LogName -After $timestamp

###
# If event ids were given, filter to keep only the events having an id in our event id list.
###
if ($EventIds) {
    $eventIdStrings = $EventIds.Split(":")
    $eventIdNums = @()
    foreach ($eventId in $eventIdStrings) {
        $eventIdNums += [convert]::ToInt32($eventId)
    }

    # Iterate over the events and copy only those we want to keep into the filteredEvents.
    $filteredEvents = @()
    foreach ($event in $events) {
        if (-Not ($eventIdNums -Contains $event.EventID)) {
            continue
        }
        $filteredEvents += $event
    }
    $events = $filteredEvents
}

###
# Add required 'event_type' to objects from Get-EventLog.
# Add optional 'log_name' value to object.
###


$events.ForEach({
    Add-Member -NotePropertyName 'event_type' -NotePropertyValue 'wineventlog' -InputObject $_
    Add-Member -NotePropertyName 'log_name' -NotePropertyValue $LogName -InputObject $_

});



###
# Create hash table in required format for Infrastructure, populated
# with event object log data and pipe to ConvertTo-Json with
# -Compress argument required in order for Infrastructure to consume.
###
$payload = @{
    name = "com.newrelic.windows.eventlog"
    integration_version = "0.1.0"
    protocol_version = 1
    metrics = @($events)
    inventory = @{}
    events = @()
} | ConvertTo-Json -Compress


###
# Output json string created above with regex to normalize date strings
# post json string conversion. Alternatively, you could create a
# new -NotePropertyName with the proper date string and remove
# the original object property. 
###
Write-Output ($payload -replace '"\\\/Date\((\d+)\)\\\/\"' ,'$1')

Thank you

Apart from Application and System we are not getting any other Event Log Details

I'm trying to get Event IDs monitored for DFS Replication. Apart from Application and Security windows logs, I'm not getting any.

image

Errors from Log:
time="2020-12-10T04:03:23-06:00" level=error msg="Integration command failed" error="exit status 1" instance=eventlog-dfsreplication integration=com.newrelic.windows.eventlog prefix=integration/com.newrelic.windows.eventlog stderr="'C:\Program' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n" working-dir="C:\Program Files\New Relic\newrelic-infra\custom-integrations"

Can you let me know how to get this issue fixed?

Modify script to change "EntryType" to an enumerated list.

Currently, the EntryType is imported into New Relic as a numeric value, but we would like to see this as an enumerated list. Perhaps we can break this into three attributes for EntryType, Code/Numeric Value and Message?

IE: Taken from here

1 | Error | An error event. This indicates a significant problem the user should know about; usually a loss of functionality or data.
16 | FailureAudit | A failure audit event. This indicates a security event that occurs when an audited access attempt fails; for example, a failed attempt to open a file.
4 | Information | An information event. This indicates a significant, successful operation.
8 | SuccessAudit | A success audit event. This indicates a security event that occurs when an audited access attempt is successful; for example, logging on successfully.
2 | Warning | A warning event. This indicates a problem that is not immediately significant, but that may signify conditions that could cause future problems.

Or something similar.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.