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.
Related
I'm trying to connect to Google Cloud SQL for MySql through Google Cloud Run. I've been through many posts at SO and also the Google documentation. But doesn't seem to get it working for myself. I admit that I have never containerized any application and I am predominantly a data person.
Note: I already have Cloud SQL instance created which I can connect through Cloud shell.
1) My code is based on Google documentation at
https://cloud.google.com/sql/docs/mysql/connect-run
and the github code at
https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/cloud-sql/mysql/sqlalchemy/main.py
2) Build the image
gcloud builds submit --tag gcr.io/my-project/my-test-image
3) Deploy the image
gcloud run deploy --image gcr.io/my-project/my-test-image
4) When I try to invoke the service in Cloud Shell using the following, I get output as "Service Unavailable"
curl -H "Authorization: Bearer $(gcloud auth print-identity-token)" https://my-service.run.app
Can anyone please help me to resolve this?
Changes -
I had not provided the mysql instance name. I corrected it and now I'm getting error as below -
[INFO] Listening at: http://0.0.0.0:8080 (1)"
"Traceback (most recent call last): File
"/usr/local/lib/python3.8/site-packages/pymysql/connections.py", line
571, in connect
sock.connect(self.unix_socket) FileNotFoundError: [Errno 2] No such file or directory"
I don't understand why it's listening at 0.0.0.0:8080. I removed the host and port from my code and I still get this "info" and the error I get is that "FileNotFoundError". I'm not sure which file it needs. Does it need some kind of connections file? If yes what's the format of the file?
I wrote a tutorial on how to Connect Cloud SQL(MySql) from Cloud Run (Java), but the flow is the same. link
Please make sure you understand the point 13, where you have to pass the instance connection name with the flag --add-cloudsql-instances, this will start the cloud sql proxi for you.
13.Configure the service for use with Cloud Run
gcloud run services update run-mysql --add-cloudsql-instances run-to-sql:europe-west2:database-external --set-env-vars CLOUD_SQL_CONNECTION_NAME=run-to-sql:europe-west2:database-external DB_USER=user_name,DB_PASS=user_password,DB_NAME=user_database
SO link
I installed a fresh gcloud sdk (in Azure Cloud Shell if it matters...)
chad#Azure:~$ gcloud --version
Google Cloud SDK 279.0.0
bq 2.0.53
core 2020.01.31
gsutil 4.47
I'm trying to run 'gcloud init' -- but the URL it renders does not work...
chad#Azure:~$ gcloud init
Welcome! This command will take you through the configuration of gcloud.
Your current configuration has been set to: [default]
You can skip diagnostics next time by using the following flag:
gcloud init --skip-diagnostics
Network diagnostic detects and fixes local network connection issues.
Checking network connection...done.
Reachability Check passed.
Network diagnostic passed (1/1 checks passed).
You must log in to continue. Would you like to log in (Y/n)?
Go to the following link in your browser:
https://accounts.google.com/o/oauth2/auth?code_challenge= I REMOVED
A BUNCH OF CODES HERE &scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth
Enter verification code:
Am I missing something?
#John Hanley -- for the win!
Can't believe I didn't think of that -- thanks much.
Chad
p.s. looks like a bug in Azure Console or Windows Terminal truncating wrapped text...
After sleeping (in lite account type) node-red, created by node-red starter kit, crashes while starting. It is possible to login in editor for a few seconds and then it crashes with error code "an instance of the app crashed: APP/PROC/WEB: Exite with status 1 (out of memory)". Dashboard (node-red-dashboard) was installed before sleeping and worked correctly.
I tried to restart Node-RED, Stop and Start.
I solved this problem. The problem may be due to the memory overflow in the container Garden. Taking into account that the content is stored in the cache, the application cannot start after the restart process, it issues an Exit status 1 (out of memory) error.
The cache is updated only by pushing the application into the cloud.
An option that was checked for application recovery:
View the name of the database for NodeRED (which stores all information about the Node-RED) in Cloudant, for example, "nodered."
Install to PC Cloud Foundry Command Line Interface - CLI https://docs.cloudfoundry.org/cf-cli/install-go-cli.html
Download from github and unarchive the application's code bluemix-starter https://github.com/knolleary/node-red-bluemix-starter (clone or download -> download zip)
In the downloaded folder add a record to a manifest file (manifest.yml) in the env section, in which set the database name (for example, nodered) in Cloudant to environment variable NODE_RED_STORAGE_DB_NAME. Four spaces must be made before NODE_RED_STORAGE_DB_NAME. It is better to make changes using the Notepad ++ editor.
---
applications:
- memory: 256M
env:
OPTIMIZE_MEMORY: true
NODE_RED_STORAGE_DB_NAME: nodered
command: node index.js --settings ./bluemix-settings.js –v
Save the file after changing.
Run the command line (cmd) and then:
a. go to a folder with a downloaded project, such as Windows
cd c:/node-red-bluemix-starter
b. specify the api endpoint where the application is located, in our case:
cf api https://api.eu-gb.bluemix.net
c. send a registration command in the cloud
cf login
d. specify the mail and password (password is entered without explicit character display)
e. pushing the project by specifying the name of your instance Node-RED, for example NameApp
cf push NameApp
I'm getting this error trying to deploy a card to a working blockchain on cloud, any idea? Thanks in advance. I'm using a mac, following the guide (Kubernetes installed/configured well, I think):
https://ibm-blockchain.github.io/interacting/
./create/create_composer-rest-server.sh --paid --business-network-card /Users/sm/jsblock/tutorial-network/PeerAdmin#fabric-network.card
Configured to setup a paid storage on ibm-cs
Preparing yaml file for create composer-rest-server
sed: 1: "s/%COMPOSER_CARD%//User ...": bad flag in substitute command: 'U'
Creating composer-rest-server pod
Running: kubectl create -f /Users/sm/jsblock/ibm-container-service/cs-offerings/scripts/../kube-configs/composer-rest-server.yaml
error: no objects passed to create
Composer rest server created successfully
There is an error in that document. And you are also specifying the Peer Admin card when you need to use a Network Admin Card.
There are 2 sets of 'parallel' documents for paid and free clusters. The command you are using has --paid in it in error. If you remove --paid and use the Network Admin Card I think it will solve the problem.
Your command will look something like this: ./create/create_composer-rest-server.sh --business-network-card admin#YOUR-network
I tried again with the install proccess (deployed blockchain instance seemed to work weall): https://ibm-blockchain.github.io/simple/
But I noticed that the script:
./create_all.sh
...never ended (mostly an internal kubernetes problems I guess). And I reset the installation:
./delete_all.sh
./create_all.sh
I tried again, now everything Ok. I could get my awesome API REST talking with my Hyperledger Blockchain, deployed on IBM Cloud. Ready to develop something amazing.
I have Java Liberty Web Application on Bluemix. If I need to update it, the app becomes unavailable for a few minutes. Is it possible to update it without turning it off? For example deploy two applications and reroute to a second one one when first is being updated?
Yep. There best way of doing this currently is via the following steps.
deploy original application on myroute.mybluemix.net
make some code changes
deploy changed application on myroute2.mybluemix.net
map myroute.mybluemix.net to the changed application using cf map-route APP_NAME DOMAIN [-n HOSTNAME]. Original application now has myroute.mybluemix.net and the changed application now has myroute.mybluemix.net & myroute2.mybluemix.net. At this point traffic will be routed equally between the two application versions (assuming they have the same number of instances).
unmap myroute.mybluemix.net from the original application using cf unmap-route APP_NAME DOMAIN [-n HOSTNAME]. All traffic on myroute.mybluemix.net will now all be routed to the newer version.
delete original application using cf delete APP_NAME
(optional) remove myroute2.mybluemix.net using cf unmap-route APP_NAME DOMAIN [-n HOSTNAME]
This seems a bit long winded but it will achieve what you want.
This is known as a blue-green deployment, and there are several cloud foundry plugins which will do it 'automatically':
Bluemix's Active Deploy service
This is new function, so it's in beta at the moment. To make the service available, you can add it from the Bluemix service catalog to your space. If you're running cf locally, you'll need to install the plugin:
cf add-plugin-repo bluemix http://plugins.ng.bluemix.net/
cf install-plugin active-deploy -r bluemix
Once it's available (either with a cf plugin install, or the catalog configuration), and you have routes, you can do
cf push --no-route new-version
cf active-deploy-create old-version new-version
Cloud Foundry community-contributed plugin for blue green deployments
You can install this using
cf add-plugin-repo garage https://garage-cf-plugins.eu-gb.mybluemix.net/
cf install-plugin blue-green-deploy -r garage
Then, to push,
cf blue-green-deploy app_name --smoke-test <path to test script>
The smoke test part is optional, but a good idea.