SOLVED

Not getting PostgreSQL Logs into Log Analytics

%3CLINGO-SUB%20id%3D%22lingo-sub-1648234%22%20slang%3D%22en-US%22%3ENot%20getting%20PostgreSQL%20Logs%20into%20Log%20Analytics%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1648234%22%20slang%3D%22en-US%22%3E%3CP%3EAccording%20to%20this%20guide%3A%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-gb%2Fazure%2Fpostgresql%2Fconcepts-server-logs%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-gb%2Fazure%2Fpostgresql%2Fconcepts-server-logs%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20do%20the%20following%20to%20enable%20the%20logs%20to%20be%20ingested%20to%20Log%20Analytics%3A%3C%2FP%3E%3COL%3E%3CLI%3EIn%20the%20portal%2C%20go%20to%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CEM%3EDiagnostic%20Settings%3C%2FEM%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ein%20the%20navigation%20menu%20of%20your%20Postgres%20server.%3C%2FLI%3E%3CLI%3ESelect%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CEM%3EAdd%20Diagnostic%20Setting%3C%2FEM%3E.%3C%2FLI%3E%3CLI%3EName%20this%20setting.%3C%2FLI%3E%3CLI%3ESelect%20your%20preferred%20endpoint%20(storage%20account%2C%20event%20hub%2C%20log%20analytics).%3C%2FLI%3E%3CLI%3ESelect%20the%20log%20type%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EPostgreSQLLogs%3C%2FSTRONG%3E.%3C%2FLI%3E%3CLI%3ESave%20your%20setting.%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20no%20idea%20where%20the%20option%20'select%20log%20type'%20is%20%3F%20This%20never%20seems%20to%20be%20present.%3C%2FP%3E%3CP%3EIgnoring%20that%20though%2C%20after%20you%20have%20done%20the%20above%20(including%20ticking%20every%20possible%20option%20for%20logging)%20then%20it%20should%20be%20a%20case%20of%20running%20AzureDiagnostics%20and%20seeing%20the%20log%20files%20come%20flowing%20in.%3C%2FP%3E%3CP%3ETrouble%20is%2C%20I%20get%20nothing%2C%20I've%20tried%20it%20in%20a%20couple%20of%20environments%20and%20both%20have%20the%20same%20problem.%3C%2FP%3E%3CP%3ESurely%20I%20should%20get%20something%20%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1657249%22%20slang%3D%22en-US%22%3ERe%3A%20Not%20getting%20PostgreSQL%20Logs%20into%20Log%20Analytics%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1657249%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F452208%22%20target%3D%22_blank%22%3E%40JK_UK%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOne%20thing%20to%20make%20sure%20which%20you%20probably%20did%20is%20that%20you%20need%20the%20instance%20to%20be%20General%20Purpose%20or%20Memory%20Optimized%20SKU.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20the%20blade%20of%20the%20PostgreSQL%20instance%20you%20should%20have%20Logs%20option%20on%20the%20left%20menu.%20That%20logs%20option%20allows%20you%20to%20query%20Log%20Analytics%20directly%20and%20any%20query%20you%20enter%20will%20automatically%20be%20scoped%20only%20to%20the%20logs%20that%20are%20generated%20by%20the%20PostgreSQL%20instance%20of%20the%20blade.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20diagnostic%20logs%20you%20have%20to%20keep%20in%20mind%20that%20these%20become%20available%20in%20AzureDiagnostics%20table%20only%20when%20such%20log%20is%20generated.%20If%20such%20log%20is%20not%20generated%20you%20might%20see%20the%20table%20empty%20for%20your%20PostrgeSQL%20instance%20until%20log%20is%20generated.%20In%20case%20you%20are%20logging%20only%20errors%20and%20warnings%20you%20might%20want%20to%20set%20the%20minimum%20log%20level%20on%20the%20PostgreSQL%20instance%20so%20you%20generate%20more%20log%20levels.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

According to this guide:

https://docs.microsoft.com/en-gb/azure/postgresql/concepts-server-logs

 

You do the following to enable the logs to be ingested to Log Analytics:

  1. In the portal, go to Diagnostic Settings in the navigation menu of your Postgres server.
  2. Select Add Diagnostic Setting.
  3. Name this setting.
  4. Select your preferred endpoint (storage account, event hub, log analytics).
  5. Select the log type PostgreSQLLogs.
  6. Save your setting.

 

I have no idea where the option 'select log type' is ? This never seems to be present.

Ignoring that though, after you have done the above (including ticking every possible option for logging) then it should be a case of running AzureDiagnostics and seeing the log files come flowing in.

Trouble is, I get nothing, I've tried it in a couple of environments and both have the same problem.

Surely I should get something ?

1 Reply
best response confirmed by JK_UK (Contributor)
Solution

Hi@JK_UK 

 

One thing to make sure which you probably did is that you need the instance to be General Purpose or Memory Optimized SKU.

 

In the blade of the PostgreSQL instance you should have Logs option on the left menu. That logs option allows you to query Log Analytics directly and any query you enter will automatically be scoped only to the logs that are generated by the PostgreSQL instance of the blade.

 

With diagnostic logs you have to keep in mind that these become available in AzureDiagnostics table only when such log is generated. If such log is not generated you might see the table empty for your PostrgeSQL instance until log is generated. In case you are logging only errors and warnings you might want to set the minimum log level on the PostgreSQL instance so you generate more log levels.