Checking Logs

If the inputs are not generating the data that you are expecting to see, there are a couple of troubleshooting measures that you can try to diagnose any issues.

  1. Run the following search to check for any error messages that have been generated that relate to MuleSoft:
index=_internal WARN OR ERROR mulesoft source="/opt/splunk/var/log/splunk/splunkd.log" 
  1. The app has an error logging system that logs information whenever an API call fails. To locate these error messages (if they exist) run the following search (adjust to your need):
index=_internal ERROR <input_name>

If there have been any errors generated, then there will be events of the form:

"input": <input_name>, 
"url": <api_endpoint>,
"status": <http_status_code>, 
"message": <JSON_text_returned>,
“org_id”: <org_id> (if present),
“env_id”: <env_id> (if present) 

If the message suggests that there are access issues, be sure that the account credentials you have provided have ‘Read Applications’ permissions in Mulesoft for the environment you are looking at.

Checking Access

You can check that the credentials you have allow access and also check the system you have deployed the TA on can reach the Mulesoft APIs by following these steps.  If these fail then your problem is external to the TA and you’ll need to fix those before the TA will have a chance:

Authenticating

Check that the credentials you have can authenticate and generate an access token (replace <username> and <password> with your mulesoft username/password):

curl -ik https://anypoint.mulesoft.com/accounts/login -X POST --data 'username=<username>&password=<password>'

The first thing to check is that the first line of the response is:

HTTP/1.1 200 OK

If your connection hangs and then times out – you’ve most likely got a network access issue (check security groups, proxy, firewalls, etc) – you’ll need internet access from the host running the TA to hit the Mulesoft API.  If you get the following message, then the credentials supplied are not working:

HTTP/1.1 401 Unauthorized

If the authentication worked then after all the HTTP headers you should get some JSON that looks like this:

{
"access_token": "4d91eddc-5446-4125-91ee-5d333055db94",
"token_type": "bearer",
"redirectUrl": "/home/"
}

You need to copy the access token for the next step.

Retrieving User and Organisation information

Run the command below to access information about the Mulesoft Organisation, including the organisation ID.  Replace <YOUR_ACCESS_TOKEN> with the access token retrieved in the “Authenticating” step above:

curl -H "Authorization: Bearer <YOUR_ACCESS_TOKEN>" https://anypoint.mulesoft.com/accounts/api/me

The command above should output JSON with details on the user account used, the organisation and more.  If this fails you should check that the user (who successfully authenticated above) has the correct access permissions.

Note that a mulesoft environment can comprise of a root organisation and a number of child organisations which are usually referred to as business groups.

Script to check access

The following script automates the two steps above  and returns a list of environments that exist, in the organisation that the user account has been created.  Note that it uses jq to help format the output.  For more information on jq, see this page.

#/bin/bash

if [ "$#" -ne 2 ]
then
echo "Enter the username and password on the command line"
echo "Example:"
echo "./discover.sh myMulesoftUser pa55word"
exit 1
fi

#Get The Access Token
accessToken=$(curl -k https://anypoint.mulesoft.com/accounts/login -X POST --data "username=${1}&password=${2}" 2>/dev/null | jq -r .access_token)

echo Access Token
echo ============
echo $accessToken
echo
#exit 0
#Get the Organization ID
orgId=$(curl -H "Authorization: Bearer ${accessToken}" https://anypoint.mulesoft.com/accounts/api/me 2>/dev/null| jq -r .user.organization.id)

echo Organization Id
echo ===============
echo $orgId
echo

#Get the Environments
envIds=$(curl -H "Authorization: Bearer ${accessToken}" https://anypoint.mulesoft.com/accounts/api/organizations/${orgId}/environments 2>/dev/null | jq '.data[] | {name, id}')

echo Environment Ids
echo ===============
echo $envIds | jq .

 

Posted by:Becky Nielsen

Becky is a certified Splunk Admin, who has been working for iDelta since graduating from CodeClan's Professional Software Development course in 2019. Previously an archivist at several institutions around the UK, she holds an MSc in Information Management and Preservation from the University of Glasgow.