WSO2: StatisticsClient - wso2

How can i use StatisticsAdmin of Application Server
My scenario is : i want to get responsetime of a service that deploy on a server(AppServer/DataServer..) and probed by ESB using discoveryproxy of governance regidtry. if is it possible how can i implement it? otherwise i should be get service response time from AppServer in direct using service name. i can create a proxy of ServerAdminMBean using this package and interface
import org.wso2.carbon.server.admin.service.ServerAdminMBean
but i need to use attributes and method of StatisticsAdmin type. how can i implement it?

you dont need to do your own implementation. it is already in the service statistics page.
You can find the service stat details in the monitor-->System Statistics page. If you need more fine grained details about your service,you might need to integrate BAM with AS.

Once you deploy any service, there's a log message prints in server back end console.(you may noticed that before). That message handled by the "LoggingAdmin" admin service. In that admin service there's a operation called "getSystemLog" and this operation sends all log messages one by one. you can create simple java class to call that admin service and get the deployed time stamp of each of the service you are deployed. if you know the service deployment start time, with above admin service you can get time taken to each of the service deployment.

You can use JMX to access those information. There is StatisticAdmin MBena available for monitoring in . You can refer this to get an idea how to invoke them using Java.

Related

Google Cloud Run - Services to discover other Internal services running within the same project

The requirement is to call other microservices running within the same GCP project using the service name instead of the full service url to get the ID token as mentioned here https://cloud.google.com/run/docs/authenticating/service-to-service.
I see a similar stackoverflow question - Google Cloud Run API - accessing endpoint internally. Here it looked like there was no direct solution from GCP and has been suggested to use runsd - https://github.com/ahmetb/runsd.
Is there something available from GCP now where a cloud run service can call another private cloud run service within the same project using "https://servicename" internally
(or)
Is it still not available and we need to use the complete service url https://--.run.app to get the ID Token and then make the call using the ID Token and the full service url?
I have tried using the full service url and ID Token to make the call. But getting the full url with the projectHash is not something we are looking for. A more uniform approach using the service name for internal call will be more easier from microservice calling perspective.
Since Google Cloud is not offering this yet. You may file a feature request to this link. However, please keep in mind that this will still be under consideration and there is no definite ETA.
You must use the whole service URL, which contains the service name, project hash, and region, together with the ID token, to perform a service-to-service call to another Cloud Run service inside the same project.
The above answer from Christian Paul Andaya is the accepted answer.

Where to Find Web Service of Delpoyed BPM in BPS Server in wso2?

I'm new to WSO2 products, I know while integrating BPS with ESB, we require the service of deployed Process
so My Question is:- Where to Find Web Service of Deployed BPM.
Deploying a BPM does not result in a Webservice, one or more processes will be deployed instead. You can find these under processes in the BPMN explorer https://[wso2server]:[port]/bpmn-explorer or they can be accessed through the BPMN rest API REST API Documentation.
If you want webservices that implement processes you should probably go with (WS-)BPEL. BPEL Reference
If you want to start/control the process from your webpage you can use the rest API. To start a process using the API you would send a POST request to the following URL:
https://<Host Name>:<Port>/bpmn/runtime/process-instances
This will create a new instance of the process you have specified in the Request body. All you need to put in the body to create the instance is either the processDefinitionId or processDefinitionKey (you can find both in the BPMN-explorer mentioned above). There are other, optional variables as well as the option to create your instance based on a message but this last option is not recommended.
{
   "processDefinitionKey":"sampleJavaServiceTask"
}
For more info on this, check out the link to the BPMN REST API

Get the name of the Application that triggers a call from WSO2 API Manager

Is it possible to get the name of the Application that triggered the API call on WSO2 API Manager and pass it on to the call as a header?
Any can help how to do this please.
Yes, application name is part of the JWT token that you get with the calls. Here's documentation.
JWT tokens are enabled by default in WSO2 API Cloud (the public hosted service from WSO2). So if you are using it - everything just works.
If you are deploying API Manager yourself, you need to configure JWT yourself as explained here.
One option would be to implement an custom handler. See Writing Custom Handlers
APIMgtUsageHandler is one of the handlers in API manager which collects the application name (to collect usage data). So you can refer it as a sample handler on how to get the application name. see APIMgtUsageHandler.java

Call asmx web service from Windows Azure Scheduler

I have an asmx web service running in a Web Role in a Windows Azure cloud application. I want to user the Windows Azure scheduler to call this service on an hourly basis. I am able to create the job but everything I have tried in the URI results in an error.
I can call the same web service successfully from a web page using ajax using a URI such as :
http://www.example.com/myservice.asmx/TheFunction
but this form returns an error (when I use either a GET or a POST):
Request format is unrecognized for URL unexpectedly ending in '/TheFunction'.
Can anyone advise what format this URI should take?
Thanks
Don't know if this will help, but our team found that if you're using the brand new Management screens from the Azure Portal to do this, you can only set the URL and the Content, but you don't appear to have access to the request headers.
We were calling into an MVC application, and found that we need to add a header variable (Content-type: application/x-www-form-urlencoded) in order for our Router / Controllers to pull the associated POST arguments. We're looking at using the API to create the job instead, as there appears to be control over the headers using this method.
See the "headers" argument within the
Create Job Method in the Scheduler API.

Using DefaultCredentials and DefaultNetworkCredentials

We're having a hard time figuring how these credentials objects work. In fact, they may not work how we expected them to work. Here's an explanation of the current issue.
We got 2 servers that needs to talk with each other through webservices. The first one (let's call it Server01) has a Windows Service running as the NetworkService account. The other one Server02 has ReportingServices running with IIS 6.0. The Windows Service on Server01 is trying to use the Server02 ReportingServices WebService to generate reports and send them by email.
So, here's what we tried so far.
Setting the credentials at runtime (This works perfectly fine):
rs.Credentials = new NetworkCredentials("user", "pass", "domain");
Now, if we could use a generic user all would be fine, however... we are not allowed to. So, we are trying to use the DefaultCredetials or DefaultNetworkCredentials and pass it to the RS Webservice:
rs.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials
Or:
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
Either way won't work. We're always getting 401 Unauthrorized from IIS. Now, what we know is that if we want to give access to a resource logged as NetworkService, we need to grant it to DOMAIN\MachineName$ (http://msdn.microsoft.com/en-us/library/ms998320.aspx):
Granting Access to a Remote SQL Server
If you are accessing a database on another server in the same domain (or in a trusted domain), the Network Service account's network credentials are used to authenticate to the database. The Network Service account's credentials are of the form DomainName\AspNetServer$, where DomainName is the domain of the ASP.NET server and AspNetServer is your Web server name.
For example, if your ASP.NET application runs on a server named SVR1 in the domain CONTOSO, the SQL Server sees a database access request from CONTOSO\SVR1$.
We assumed that granting access the same way with IIS would work. However, it does not. Or at least, something is not set properly for it to authenticate correctly.
So, here are some questions:
We've read about "Impersonating Users" somewhere, do we need to set this somewhere in the Windows Service ?
Is it possible to grant access to the NetworkService built-in account to a remote IIS server ?
Thanks for reading!
All details you need are included in this very old article
In short, when you find it confusing to troubleshoot issues like this, you should first review the technical details behind ASP.NET impersonation carefully.
Here are some things you could check out:
- set an SPN (Service Principal Name) for the reporting service; you can find good examples in google;
- Allow delegation (ClientCredentials.Windows.AllowImpersonationLevel)
Is the problem that you're failing to authenticate to IIS, or failing to authenticate to SSRS? The DOMAIN\MachineName$ account may need to be granted permission in SSRS to run the report you're trying to automate.
SSRS usually does a pretty good job of getting IIS configured correctly, so you shouldn't need to mess with those settings. I double-checked my installation (which is SSRS 2005, things may have worked differently in SSRS 2000 and you didn't say which version you're running), and it's set to use Windows authentication and has impersonation enabled. That means IIS should basically just be authenticating your credentials (validating a correct username/password), not authorizing (determining whether that user has permission to run the report in question). IIS then passes the credentials on to SSRS, which has its own settings for determining what accounts have permission to view reports.
Also, you can automate sending reports on a scheduled basis directly in SSRS, so you may not need the Windows service at all if your scheduling is fairly basic (i.e., daily, weekly, etc.).