Getting Data In

Is it possible to use the HTTP Event Collector with Morgan?

tper1992
New Member

In my Node.js(Express) Application I use Morgan as the logging library. Can we pass the logs to an Splunk Enterprise server using a HEC?

0 Karma

tper1992
New Member

Thanks.

Those documentation does not contain anything related to Morgan. But we can easily create a Splunk Logger object and pass it as the output for the Morgan.

var MorganLogger = morgan({
  "format": "dev",
  "stream": {
    write: function(message) {
      var payload = {
        message
      };
      SplunkLogger.send(payload); }
  }
});

const app: express.Application = express();
+app.use(MorganLogger);
0 Karma

esix_splunk
Splunk Employee
Splunk Employee

Morgan should have the ability to pass token to a http endpoint based on the documentation Ive read.

Check out the HEC docs if you havent: http://docs.splunk.com/Documentation/Splunk/latest/Data/UsetheHTTPEventCollector . Additionally, check out the HEC docs on dev : http://dev.splunk.com/view/event-collector/SP-CAAAE6M

Let us know your results!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Maximizing the Value of Splunk ES 8.x

Splunk Enterprise Security (ES) continues to be a leader in the Gartner Magic Quadrant, reflecting its pivotal ...