Closed jremerich closed 3 years ago
well this does not seem to follow the docs, just look here: https://github.com/vanthome/winston-elasticsearch#usage
Hi!
I'm following the docs where it says "Logs correlation with Elastic APM", here: https://github.com/vanthome/winston-elasticsearch#logs-correlation-with-elastic-apm
However, I tried using as you mentioned and brings an error saying something like "getBody is empty", so I debug this and elasticsearch libs and I saw that when I run the code it tries to startup the index and his mapping on file bulk_writer.js
but the request returns 405 as status code with an empty body.
Here is my actual code:
const apm = require('elastic-apm-node').start({
serviceName: '[APM-Service]',
environment: process.env.NODE_ENV,
// secretToken: '',
// Set custom APM Server URL (default: http://localhost:8200)
serverUrl: 'http://[ELASTIC APM]:8200'
});
// const { Client } = require('@elastic/elasticsearch')
// const client = new Client({ node: 'http://[ELASTIC IP]:9200' })
var winston = require('winston');
var {ElasticsearchTransport} = require('winston-elasticsearch');
// import { ElasticsearchTransport } from 'winston-elasticsearch';
var esTransportOpts = {
apm,
level: 'info',
dataStream: true,
clientOpts: { node: "http://[ELASTIC IP]:9200" }
// client
};
var logger = winston.createLogger({
apm,
transports: [
new ElasticsearchTransport(esTransportOpts)
]
});
logger.error('TESTE');
export { logger };
Why are you providing the apm
instance to the logger as well?
Apart from that where in bulk_writer.js
are you getting this code?
Also you might run your application with export DEBUG=winston:elasticsearch
. Maybe you see more debug output then.
Hi!
I'm trying to use as a correlation with Elastic APM and following docs I did the code below:
But it fails showing an error message:
Elasticsearch is not a constructor
The APM is configured and working correctly.
I'm using Node.js 12 (docker image
node:12-alpine
) without typescript.Thanks!