FATAL log is marked as INFO on Google Cloud Kubernetes - kubernetes

I have an app using Rails 2.5.1 which is deployed on Google Cloud Kubernetes but the logs are not working good.The FATAL errors are displayed as INFO logs instead of ERROR or CRITICAL.
Extra context:
Rails 5.2.1
This view is from Logs Viewer
I'm using RAILS_LOG_TO_STDOUT=true. If I remove this, logs are not displayed at all
Thanks.
[UPDATE]
I updated my cluster to use the newest Stackdriver API but it stills not working and Rails.logger.error is displayed as INFO.

I got this working changing the log format to use JSON.
config.log_formatter = proc do |severity, datetime, progname, msg|
message = msg
message << " from #{progname}" if progname.present?
content = JSON.dump(timestamp: datetime.to_s, severity: severity, message: message)
content << "\n"
content
end

Have a look at the documentation Cloud Logging for Legacy Logging and Monitoring section Best practices:
Severities: By default, logs written to the standard output are on the
INFO level and logs written to the standard error are on the ERROR
level. Structured logs can include a severity field, which defines the
log's severity.
and because you're using RAILS_LOG_TO_STDOUT=true log events generated by Ruby you can see with severity INFO.
Keep in mind that you should migrate to Kubernetes Engine Monitoring:
Warning: Legacy Logging and Monitoring support for Google Kubernetes
Engine is deprecated. If you are using Legacy Logging and Monitoring,
then you must migrate to Kubernetes Engine Monitoring before support
for Legacy Logging and Monitoring is removed.
it's better to return to this "issue" after migration.
EDIT Have a look at the documentation Writing Logs section Writing log entries where you can find an example for Ruby:
Here is some sample code to write a single log entry to mylog. The
service, region, labels, and other content will change depending on
the entry and the application doing the writing.
require "google/cloud/logging"
logging = Google::Cloud::Logging.new project: "my-gcp-project-id"
entry = logging.entry entry.log_name = "my_application_log"
entry.payload = "Log message"
entry.severity = :NOTICE
entry.resource.type = "gae_app"
entry.resource.labels[:module_id] = "default"
entry.resource.labels[:version_id] = "20160101t163030"
logging.write_entries entry

Related

IBM Cloud Code Engine: How to check logs when app not active?

I have deployed an app to IBM Cloud Code Engine. It has the minimum instances configured to zero, so truly serverless and only active on demand. Now I wanted to check the logs from the CLI with
ibmcloud ce app logs --name myapp --all
it comes back with this message:
FAILED No instances running for application 'myapp'. Verify that
the application name is correct and it is running
How can I check the application logs after it has run?
The Code Engine application (and job) logs can be seen once Application Logging has been enabled. The logs are then available in a separate IBM Cloud Logging dashboard.
I also found this old blog post exlaining how to enable CLI access to those logs. After enabling it I was able to retrieve the app logs using my CLI / development environment.
Depending on what I am after, I am using one of these three lines to get to the log data / lines:
python3 searchLogDNA.py myconfig.json 12 "search term" | jq
for pretty printing, or
python3 searchLogDNA.py myconfig.json 12 "search term" | jq "._line"
to extract the actual log line from the record, or
python3 searchLogDNA.py myconfig.json 12 "search term" | jq "._line | fromjson`"
to turn the string with JSON data in the log line to actual JSON output.

WSO2 API Manager - APIs missing after recreating a pod

We have a setup of WSO2 API Management in a distributed pattern (pattern-3) in Kubernetes. We are using a PostgreSQL DB which is running outside the Kubernetes cluster for all the databases.
I have published some APIs in the publisher and am able to invoke them from the store.
I had to make a change in api-manager.xml for the API Publisher and API Store configmap files and recreated the pod. When the pods were available, I observed that the APIs that I had published and working earlier are not visible anymore.
I tried to add the same APIs again and it is complaining that the APIs by that name already exists.
Following is the log from the plubisher pod:
[2019-05-16 08:19:38,266] ERROR - APIProviderHostObject Error occurred while adding the document. PizzaShack API Documentation already exists for API PizzaShackAPI-1.0.0
[2019-05-16 08:19:38,273] ERROR - docs:jag org.wso2.carbon.apimgt.api.APIManagementException: Error occurred while adding the document. PizzaShack API Documentation already exists for API PizzaShackAPI-1.0.0
While creating the API again on the Publisher, following error is displayed: "Duplicate API Name"
It clearly seems to be some synchronization issue. How can this issue be fixed?
I had shared the instance of Carbon DB across the components. This was causingthe issue. Using separate instance for each component in disbuted mode solved it

Identify reasons for 500 errors Google auth

We have an api deployed on Azure that uses Google authentication. Over the weekend, the API started to throw 500 errors that were resolved after restarting the API. Is there a way to identify what the underlying cause for these errors might be?
Check if you have custom error mode in web.config file to “on” or “Remoteonly”. If
yes then turn it off. Add the following line to System.web element in web.config
Enable custom logging/instrumentation in the code which can help you in more
information.
ASP.NET applications can use the System.Diagnostics.Trace class to log information to
the application diagnostics log. For example
System.Diagnostics.Trace.TraceError("If you're seeing this, something bad happened");
Enable Detailed Error Messages - Detailed version of the html files produced when
your website responds with an error message. This is good to enable for debugging
some error responses in your website. It is stored in the website's file system.
Web Server Logging - Also known as HTTP logs or IIS logs, this will log all requests
to your website in W3C Extended Log File Format.
Failed Request Tracing - Also known as FREB, here you can get lots of information
from IIS through its different stacks for each failing request.

IBM Cloud Private CE - Unauthorized Access to Catalog

I have installed ICP CE 2.1.0 on a google cloud VM and the installation has gone well-no errors in installation process. When accessing the GUI I am able to see deployments and services but as soon as I access any part of the Catalog I get a blank white page with the text:
{"statusCode":401,"details":"Unexpected response code 401 from request:\nGET https://xx.xxx.xxx.xx:8443/console/api/v1/header?serviceId=catalog-ui&dev=false&accessUrl=https%3A%2F%2Fxx.xxx.xxx.xx%3A8443* ...... }
I have tried killing the individual pods but I get same error. When looking a the pod logs for the catalog-ui I have error 500 messages.
Has anyone experienced this or can tell my why this is the case? Understand that a cloud VM is not the best use case maybe but it should work?
Can you confirm the version level of ICP? Your post mentioned "ICP CE 2.1.0" but if you can check the user icon (top right corner) and click About, we should be able to see the full version details.
Reason for asking is that, at the 2100 level there was an intermittent catalog issue just like you describe. Generally it was caused by resource constraints on the k8s.
Details for ICP 2103, which is the latest available release:
https://www.ibm.com/support/knowledgecenter/SSBS6K_2.1.0.3/getting_started/whats_new.html

Trouble adding a new service

I have followed the instructions at https://github.com/cloudfoundry/oss-docs/tree/master/vcap/adding_a_system_service and copied the echo service and created my new service. (That document is somewhat out-of-date in that "excluded components" no longer exists.
In any case, my service shows up as running with a gateway and a node when I look at 'vcap status' on the server. However, when I look at 'vmc services' from the client my service is not in the list. Where is this list maintained and why is my service not on the list?
Various services, including blob, filesystem, mongodb, etc, are shown on the 'vcm services' list even though they have never been included in my config. Where is this maintained and why are other services on this list?
The cloud_controller.log file shows a "Create service request:" for echo every minute. This service is not in my config file (it was once but it was removed and I repeated the deployment). What is prompting this request for a service that was not defined in the config?
The _gateway.log for my service shows the following:
INFO -- Sending info to cloud controller: ...api.vcap.me/services/v1/offerings
INFO -- Fetching handles from cloud controller .../offerings/.../handles
ERROR -- Failed registering with cloud controller, status=400
DEBUG -- [GaaS-Provisioner] Connected to node mbus..
ERROR -- Failed fetching handles, status=404
Why does my gateway fail to register with the cloud controller? I have found some reports that suggest that the problem is with domain name mapping. I have verified that the server can find itself:
$curl api.vcap.me
Welcome to VMware's Cloud Application Platform
What can I do to register my service?
You can also try asking your question on the vcap_dev google group.
https://groups.google.com/a/cloudfoundry.org/forum/?fromgroups#!forum/vcap-dev
They are focused in answering and discussing OSS subjects for Cloud Foundry!
If you follow the document correctly things should work just fine. I understand that the mechanism for maintaining the excluded list of components has changed and can be a point of confusion when following the steps mentioned in the article (just ignore that step totally).
ERROR -- Failed registering with cloud controller, status=400
Well this is a point of worry. I recently followed the article step by step and was able to add a new service.
Is the echo service showing up in vmc services?
Have you copied the the yml files for node and gateway at ./cloudfoundry/.deployments/devbox/config?
Are the tokens for your gateway unique? and matching in the two files? ./cloudfoundry/.deployments/devbox/config/cloud_controller.yml and ./cloudfoundry/.deployments/devbox/config/**_gateway.yml**
I would recommend that you first concentrate on getting the echo service to be listed in the vmc services output. Once done with this you should replicate the steps (with absolute care to modify things like the token) to get your custom service working.
Cheers,
Ankit
You should follow this guide
It work to me.
regards.