ovhemert / pino-applicationinsights

A transport for pino that sends messages to Azure Application Insights
MIT License
10 stars 12 forks source link

Messages not being sent to/received by Azure Insights #42

Open kf6kjg opened 3 years ago

kf6kjg commented 3 years ago

šŸ› Bug Report

The messages sent to Applications Insights do not appear to be being received.

To Reproduce

Steps to reproduce the behavior:

$ echo '{"level":50,"time":1617656797803,"pid":82,"hostname":"fd712adddba1","msg":"Test at level 50."}' | npx pino-applicationinsights --key REDACTED
logging

The REDACTED value in the above comes from the Application Insights Instrumentation Key line, the location of which on the Azure Portal interface is highlighted in green here: image

Open an additional terminal and run the following

az login
az monitor app-insights query --app REDACTED --analytics-query 'traces'

The REDACTED value here is the Application ID located under the API Access sidebar.

Alternatively, use the Logs sidebar and query for traces.

Expected behavior

The logger to send the log object to the Azure Insights service and then the latter to be able to show the resulting entry.

Your Environment

kf6kjg commented 3 years ago

According to the Azure documentation it looks like the instrumentation keys are being phased out in favor of connection strings. It's possible that this is the source of the disconnect?

gboston commented 3 years ago

@kf6kjg Any fix for this?

kf6kjg commented 3 years ago

@kf6kjg Any fix for this?

None that I'm aware of at this time.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

kf6kjg commented 3 years ago

AFAICT this is still a problem, though I've not tried reproducing it since I reported it.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

devinrhode2 commented 2 years ago

I recently got application insights logging working just fine, using next.js and next-logger, pino-ms, and pino-applicationinsights.

I am using the connection string in place of the instrumentation key. The MS docs don't make it very clear. But it seems anywhere you would use an instrumentation key ("iKey") you can use a connection string.

https://github.com/atkinchris/next-logger/issues/12

In next.config.js, if process.env.APPINSIGHTS_CONNECTIONSTRING is not defined, I recommend crashing so a build+deploy does not go through. Unfortunately, why that env var would not come through is an azure issue, has nothing to do with pino-applicationinsights. But if you have that issue, I'm not opposed to comparing your pipeline file to ours.

devinrhode2 commented 2 years ago

As I've had this working, I recommend closing the issue. Maybe the issue was solved by some other related dependency, maybe INSTRUMENTATION_KEY just does not work anymore, idk.

kf6kjg commented 2 years ago

If that be the case, then maybe a documentation update is all that is needful.

devinrhode2 commented 2 years ago

I seem to have been mistaken in my previous analysis. In azure portal under "Diagnose and Solve Problems" it shows "Application Logs" (stdout) from my node server, without any of my logging code.

kf6kjg commented 2 years ago

Application Insights != stdout. Iā€™d expect nothing on stdout.

On Fri, Mar 4, 2022 at 1:14 AM Devin Rhode @.***> wrote:

I seem to have been mistaken in my previous analysis. In azure portal under "Diagnose and Solve Problems" it shows "Application Logs" (stdout) from my node server, without any of my logging code.

ā€” Reply to this email directly, view it on GitHub https://github.com/ovhemert/pino-applicationinsights/issues/42#issuecomment-1058979929, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAI2Q2F4IPBK5ROK5TLDSKLU6HH7JANCNFSM42NQ7QLA . You are receiving this because you were mentioned.Message ID: @.***>

devinrhode2 commented 2 years ago

Yeah I noticed when ApplicationInsights setup code runs, there isn't anything printed to stdout except this:

ApplicationInsights:An invalid instrumentation key was provided. There may be resulting telemetry loss [ 'asdf' ]
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.