I am trying to use Fabric whith java shim and I am still searching how to display logs on the peer output ?
I tried this :
peer node start --logging-level DEBUG
also searching to use the logger of the parent class :
private static Log logger = LogFactory.getLog(ChaincodeBase.class);
without success. Cannot see the outputs on the peer
Does anyone has an idea ?
I found myself the solution. It implies to access the Docker image inside the peer and call :
docker logs mycontainersidwhatever
but i think is could be still buggy as I am in DEBUG mode, and I see now only WARN level for the chaincode
When you instantiate a new chaincode, the peer will create a new docker container called dev-(peer name)-(contract name)-(contract version). You can see logs direct in this container.
However, fabric java chaincode uses its own logging configuration, and it uses an environment variable called CORE_CHAINCODE_LOGGING_LEVEL to define the logging level the chaincode will use. Usually, this environment variable is set to 'info' level. You can manually update the value of this variable inside the docker container running the contract, or you can define this variable into the peer, so every contract will the the defined value to it.
In 'fabric-samples\first-network\base\peer-base.yaml' ensure you have the following before you start HLF network, and then spin up the network.
FABRIC_LOGGING_SPEC=DEBUG
This will generate logs in DEBUG mode. Now, in order to see these logs that are generated within docker contaner, we'll have to ask docker for logs, and that can be done using in a terminal window.
docker logs -f <<container-name>>
Use
docker logs container_name
Or inside your docker_compose.yaml, set logging environment
FABRIC_LOGGING_SPEC=DEBUG
Or else,
try setting up in you cli for one time use
export
Related
I am trying to debug my app in testing environment, my app is running in pod, I said 'pod' because I am not familiar with Kubernetes, its manage client looks like this:app running schematic diagram. I have learn I should set idea like this idea RUN/Debug Configurations schematic diagram. And should restart and redeploy my app, I changed Dockfile firstly. the origin instruction is FROM xxx/java:alpine VOLUME /tmp ADD recruitment.jar app.jar ENTRYPOINT ["java","-Xmx2048m","-jar","/app.jar"] and I changed this to FROM xxx/java:alpine VOLUME /tmp ADD recruitment.jar app.jar ENTRYPOINT ["java","-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005","-jar","/app.jar"] but it always show error like this Error running 'face_remote': Unable to open debugger port (888.88.888.888[not real]:5005): java.io.IOException "handshake timeout". I am not sure with this ip,sicne I use 'ping 888.88.888.888' instruction can not success. I use this ip because Swagger request url's domain name's ip is this.this main enter image description here. and I guess if the app is running in docker or k8s and it will have a different Interactive mode. not same like just running in linux
most of the attached image are not visible.
IP address should be accessible from your local system
[888.88.888.888] note sure this is correct.
debug port also need to be mapped from your local system
-use port forwarding
ex:kubectl port-forward 5005:5005
If you have configure port forwarding then you can use localhost:5005 for debugging
I see three things that you can check:
Check the IP address:
The jar file runs inside a Docker container, which runs inside a pod. To access the pod you usually go through a service and an ingress. The ip you are using is most likely hitting the ingress/service or any other higher layer.
To attach a remote debugger, you will need to connect directly to the PodIP. One way of doing this is to first connect to your kubernetes cluster using the tool kubectl (some configuration required) and make a port forward from your pod: kubectl port-forward my-pod-c93b8b6df-8c4aa 5005:5005 pod (as an example, the pod instance name is my-pod-c93b8b6df-8c4aa).
This will open a connection from your local computer into the pod. Then you will need to identify the PodIP by kubectl describe pods my-pod-c93b8b6df-8c4aa and use that in IntelliJ
Check if the port is exposed:
Make sure you expose the port 5005 from the pod in your test environment (similar to exposing a port when you run the container locally).
How to do this depends a bit on how you are running your Kubernetes cluster. If you use Helm chart, you can just add a configuration like this in the port section of your deployment yaml:
- containerPort: 5005
name: debug
protocol: TCP
Check debug-command address:
Last thing is to make sure you are adding the correct address in the command line option. As IntelliJ suggest in the debug editor: for JDK9+ use …suspend=n,address=*:5005 and for JDK8 and below use …suspend=n,address=5005
i have a java spring app that runs just fine locally with gradle, but when i run the image version of it, i get a strange error that i am not sure how to resolve or debug
docker run -it --rm myregistry.azurecr.io/my-app:latest
is the command that i get the following error on:
I/O exception (java.net.SocketException) caught when processing request to {s}->https://rt.services.visualstudio.com:443: Invalid argument or cannot assign requested address
ive found out thru googling that this url https://rt.services.visualstudio.com:443 is associated with Application Insights (azure logging) which is one of my dependencies. does this mean something is wrong with logback?
the thing is, when i run with gradle, i see trace logs in the app insights instance i am trying to log to, so i know that connection is working outside of docker.
one thing to note is that in the deployed dockerized instance, i see the same logs on startup as the successful local gradle output, but then it dies after it sets the profile. maybe meaning that it is dying during the tomcat initialization.
what to do/try here?
this ended up being due to a web proxy issue, switching networks or creating a proxy rule are solutions.
Could you please assist me with the following issue.
I use Apiman version 1.2.1
FROM jboss/wildfly:9.0.2.Final
ENV APIMAN_VERSION 1.2.1.Final
I expose this version via kubernetes, as a persistent volume I use postgres in the same container. Once I create it at the first time, after this in the apiman I have added Organization/ API/.... and all necessary staff.
I press on button to publish api, and may check that it works perfect, so I use kubectl port-forward pod-name 8080:8080 and may check my gateway via browser http:localhost:8080/apiman-gateway/ORgId/bla/bla/bla/bla?givemedescriptionbyid=1.
After this one I go to console and kill apiman pod, as a result of pod restart, the same operation kubectl port-forward new-pod-name 8080:8080, and I can see that the all data of apiman like organization, apis and all other staff is already there.
But one big problem if you try to call gateway again, it tells you that:
{"responseCode":500,"message":"API not
found.","trace":"io.apiman.gateway.engine.beans.exceptions.InvalidApiException:
API not found.\n\tat
io.apiman.gateway.engine.impl.ApiRequestExecutorImpl$3.handle(ApiRequestExecutorImpl.java:278)\n\tat
io.apiman.gateway.engine.impl.ApiRequestExecutorImpl$3.handle(ApiRequestExecutorImpl.java:271)\n\tat
io.apiman.gateway.engine.impl.SecureRegistryWrapper$1.handle(SecureRegistryWrapper.java:122)\n\tat
io.apiman.gateway.engine.impl.SecureRegistryWrapper$1.handle(SecureRegistryWrapper.java:111)\n\tat
io.apiman.gateway.engine.es.CachingESRegistry.getApi(CachingESRegistry.java:116)\n\tat
io.apiman.gateway.engine.impl.SecureRegistryWrapper.getApi(SecureRegistryWrapper.java:111)\n\tat
io.apiman.gateway.engine.impl.ApiRequestExecutorImpl.execute(ApiRequestExecutorImpl.java:270)\n\tat
io.apiman.gateway.platforms.servlet.GatewayServlet.doAction(GatewayServlet.java:232)\n\tat
io.apiman.gateway.platforms.servlet.GatewayServlet.doGet(GatewayServlet.java:77)\n\tat
javax.servlet.http.HttpServlet.service(HttpServlet.java:687)\n\tat
javax.servlet.http.HttpServlet.service(HttpServlet.java:790)\n\tat
io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:86)\n\tat
io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)\n\tat
io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)\n\tat
org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)\n\tat
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\n\tat
io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)\n\tat
io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)\n\tat
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\n\tat
io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)\n\tat
io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)\n\tat
io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)\n\tat
io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:72)\n\tat
io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)\n\tat
io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)\n\tat
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\n\tat
org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)\n\tat
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\n\tat
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)\n\tat
io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:282)\n\tat
io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:261)\n\tat
io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:80)\n\tat
io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:172)\n\tat
io.undertow.server.Connectors.executeRootHandler(Connectors.java:199)\n\tat
io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:774)\n\tat
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n\tat
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\n\tat
java.lang.Thread.run(Thread.java:745)\n"}
I can see, that by metrics of calls in api manager, all my calls can reach apiman-gateway, but I get 500 response code.
If anybody will met such error, so, I have solved it with the following steps, first of all we need to use only new version of APIMAN, list of fixes already implemented. And also apiman-gateway cannot live without elastic search to restore itself. Hence elasticsearch configuration should to be provided.
I am trying to setup an application server for AWS Lambda but on a local network so that an application won't have to go out to the internet to execute. I would prefer to use a linux box and my programming environment is Java.
The skill from the echo will execute and then communicate with the local server rather than going out to the internet and communicating with Amazon's application server.
My question is this: How do I setup the application server to handle the skill? I've done the example from Amazon, do I only need to have the linux box run the Java application or is there more to the setup than that? I see there are AMIs (Amazon Machine Images) but can I deploy those locally or are they only for use on the AWS console?
Any insight into this would be great, thank you.
So this is how usual interaction between echo works:
User--->Echo--->Skill--->(Internet)Applicaton server (I'm using Amazon hosted AWS lambda)
I would like to use :
User--->Echo--->Skill--->(LAN)Application server (without ever using the internet).
Currently I have setup echo and a skill but no application server on the LAN. What do I need for the application server? JAWS and something else?
I'm not sure if this question is still relevant or not, but I'm using DEEP Framework to test the code locally and/or deploy it on AWS Lambda. Check this out:
npm install deepify -g
deepify run-lambda --help
run-lambda#1.6.8 - Run Lambda function locally
Usage example: deepify run-lambda path/to/the/lambda -e='{"Name":"John Doe"}'
Arguments:
path: The path to the Lambda (directory of handler itself)
Options:
--event|-e: JSON string used as the Lambda payload
--skip-frontend-build|-f: Skip picking up _build path from the microservices Frontend
--db-server|-l: Local DynamoDB server implementation (ex. LocalDynamo, Dynalite)
--version|-v: Prints command version
--help|-h: Prints command help
Also, you might want consider using the server option:
deepify server --help
server#1.6.9 - Run local development server
Usage example: deepify server path/to/web_app -o
Arguments:
path: The path to the Lambda (directory of handler itself)
Options:
--build-path|-b: The path to the build (in order to pick up config)
--skip-frontend-build|-f: Skip picking up _build path from the microservices Frontend
--skip-backend-build|-s: Skip building backend (dependencies installation in Lambdas and linking aws-sdk)
--skip-build-hook|-h: Skip running build hook (hook.build.js)
--port|-p: Port to listen to
--db-server|-l: Local DynamoDB server implementation (ex. LocalDynamo, Dynalite)
--open-browser|-o: Open browser after the server starts
--version|-v: Prints command version
--help|-h: Prints command help
Disclosure: I am one of the contributors to this framework
I have a Tomcat installation where I suspect the thread pool may be decreasing over time due to threads not being properly released. I get an error in catalina.out when maxthreads is reached, but I would like to log the number of threads in use to a file every five minutes so I can verify this hypothesis. Would anyone please be able to advise how this can be be done?
Also in this installation there is no Tomcat manager, it appears whoever did the original installation deleted the manager webapp for some reason. I'm not sure if manager would be able to do the above or if I can reinstall it without damaging the existing installation? All I really want to do is keep track of the thread pool.
Also, I noticed that maxthreads for Tomcat is 200, but the max number of concurrent connections for Apache is lower (Apache is using mod_proxy and mod_proxy_ajp (AJP 1.3) to feed Tomcat). That seems wrong too, what is the correct relationship between these numbers?
Any help much appreciated :D
Update: Just a quick update to say the direct JMX access worked. However I also had to set Dcom.sun.management.jmxremote.host. I set it to localhost and it worked, however without it no dice. If anyone else has a similar problem trying to enable JMX I recommend you set this value also, even if you are connecting from the local machine. Seems it is required with some versions of Tomcat.
Just a quick update to say the direct JMX access worked. However I also had to set Dcom.sun.management.jmxremote.host. I set it to localhost and it worked, however without it no dice. If anyone else has a similar problem trying to enable JMX I recommend you set this value also, even if you are connecting from the local machine. Seems it is required with some versions of Tomcat.
Direct JMX access
Try adding this to catalina.sh/bat:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=5005
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
UPDATE: Alex P suggest that the following settings might also be required in some situations:
-Dcom.sun.management.jmxremote.host=localhost
This enables remote anonymous JMX connections on port 5005. You may also consider JVisualVM which is much more please and allows to browse JMX via plugin.
What you are looking for is Catalina -> ThreadPool -> http-bio-8080 -> various interesting metrics.
JMX proxy servlet
Easier method might be to use Tomcat's JMX proxy servlet under: http://localhost:8080/manager/jmxproxy. For instance try this query:
$ curl --user tomcat:tomcat http://localhost:8080/manager/jmxproxy?qry=Catalina:name=%22http-bio-8080%22,type=ThreadPool
A little bit of grepping and scripting and you can easily and remotely monitor your application. Note that tomcat:tomcat is the username/password of user having manager-jmx role in conf/tomcat-users.xml.
You can deploy jolokia.war and then retrieve mbeans values in JSON (without the manager):
http://localhost:8080/jolokia/read/Catalina:name=*,type=ThreadPool?ignoreErrors=true
If you want only some values (currentThreadsBusy, maxThreads, currentThreadCount, connectionCount):
http://localhost:8080/jolokia/read/Catalina:name=*,type=ThreadPool/currentThreadsBusy,maxThreads,currentThreadCount,connectionCount?ignoreErrors=true
{
request: {
mbean: "Catalina:name="http-nio-8080",type=ThreadPool",
attribute: [
"currentThreadsBusy",
"maxThreads",
"currentThreadCount",
"connectionCount"
],
type: "read"
},
value: {
currentThreadsBusy: 1,
connectionCount: 4,
currentThreadCount: 10,
maxThreads: 200
},
timestamp: 1490396960,
status: 200
}
Note: This example works on Tomcat7 +.
For a more enterprise solution. I have been using New Relic in our production environment.
This provides a graph of the changes to the threadpool over time.
There are cheaper tools out meanwhile: I am using this jar here: https://docs.cyclopsgroup.org/jmxterm
You can automate it via shell/batch scripts. I regexed the output and let prometheus poll it for displaying it in grafana.