Configuring Syslog Settings on Edge Gateway in vCloud Air via Rest API

By | 06/08/2017

Recently I deployed syslog server in my vCloud Lab and was looking for a way to send Edge gateway logs to my syslog server. This post in focused on how to configure edge gateway syslog settings. 

VMware vCloud® Air supports the ability for customers to collect information about traffic coming to and from their edge gateway through the use of a syslog server. By configuring edge gateway to transfer log data to your syslog server, you can then set up alerts or notifications and build reports with your preferred tools.

If you do not have ANS subscription in vCloud Air then the only way to configure syslog settings on the Edge gateway is via vCloud API. There is no option available in GUI when you open edge gateway properties from within vCloud Director interface.

When it comes to using Rest API we have variety of choice to use as Rest Client. Some of the common clients include curl, Postman,Mozilla rest Client etc.

I personally prefers curl and postman and in this post I will demonstrate the curl option.

Requirements to Configure Syslog on Edge Gateway:

1: A REST client.

2: vCloud Air credentials.

3: vCloud Air Endpoint/Org name.

4: Configured syslog server and IP address.

Obtaining vCloud Air Endpoint/Org name

You can obtain the endpoint details by logging into vCloud Air portal and navigating to your Org/vDC.

Obtaining vCloud Air supported API versions

List of supported API versions that can be used with vCloud Air can be obtained by firing below command. 

# curl -sik -H “Accept:application/*+xml;version=5.6” -u “mjha@vmware.com” -X GET https://au-south-1-15.vchs.vmware.com/api/versions

You will get a long list of versions as output. Select any one of the version. Also make a note of the login URL. 

Obtaining Auth Code for vCloud API Login

You need 4 things for generating Auth code for API login

A: Login URL (copy from previous output)

B: API Version: (copy from previous output)

C: Customer Header: Accept:application/*+xml;version=9.0

D: vCloud Air Credentials in format: username@domain-name@org-name

When you have all the 4 info handy, fire below API query to obtain Auth code

# curl -sik -H “Accept:application/*+xml;version=9.0” -u “mjha@vmware.com@bdd75fd4-a319-47d5-b4f2-77aad691488f” -X GET https://au-south-1-15.vchs.vmware.com/api/compute/api/sessions | grep auth

Enter host password for user ‘mjha@vmware.com@bdd75fd4-a319-47d5-b4f2-77aad691488f’:

Post entering password, you will be provided with Auth token

x-vcloud-authorization: 1e95dc1064aa4083ae79bb617221853e

Now use following API queries in sequence

Find Org UUID

# curl -sik -H “Accept:application/*+xml;version=5.6” -H “x-vcloud-authorization:1e95dc1064aa4083ae79bb617221853e” -X GET https://au-south-1-15.vchs.vmware.com/api/org/ | grep bdd75fd4-a319-47d5-b4f2-77aad691488f    

Note: bdd75fd4-a319-47d5-b4f2-77aad691488f is my org name.

You will get the org href in the output

Find vDC UUID

# curl -sik -H “Accept:application/*+xml;version=5.6” -H “x-vcloud-authorization:1e95dc1064aa4083ae79bb617221853e” -X GET https://au-south-1-15.vchs.vmware.com/api/compute/api/org/4f5feba5-bb82-456e-8898-95d4970f2624 | grep vdc

List all edge gateways in your Org

# curl -sik -H “Accept:application/*+xml;version=5.6” -H “x-vcloud-authorization:1e95dc1064aa4083ae79bb617221853e” -X GET https://au-south-1-15.vchs.vmware.com/api/compute/api/vdc/e89232de-3507-4b66-98d7-8ec25e99c826 | grep edge

Find Edge Gateway UUID

# curl -sik -H “Accept:application/*+xml;version=5.6” -H “x-vcloud-authorization:1e95dc1064aa4083ae79bb617221853e” -X GET https://au-south-1-15.vchs.vmware.com/api/compute/api/admin/vdc/e89232de-3507-4b66-98d7-8ec25e99c826/edgeGateways | grep EdgeGatewayRecord

Once you obtain the edge UUID we need to update the edge by supplying a custom xml file which will enable the syslog settings. 

First create an xml file with below content

Now execute below API call to configure the syslog settings.

# curl -sik -H “Accept:application/*+xml;version=5.6” -H “Content-Type:application/*+xml” -H “x-vcloud-authorization:1e95dc1064aa4083ae79bb617221853e” -X POST https://au-south-1-15.vchs.vmware.com/api/compute/api/admin/edgeGateway/199fd7be-49fc-4cfb-862e-cb85e9cc4f6c/action/configureSyslogServerSettings -d @syslog.xml

You should see a Http 202  Accepted in output and the task details

HTTP/1.1 202 Accepted Date: Sun, 06 Aug 2017 06:28:55 GMT

Open the edge gateway properties again and verify syslog server IP is now present.

On my syslog server I can see log files getting populated

[root@syslogsrv vse-40b96734-3311-48ea-9b91-a34cf2efc0bc-0]# ls
config.log firewall.log monit.log syslog-ng.log

Also in /var/log/messages I can see log entries from edge gateway

Additional Sources

Configure Syslog Settings on vCloud Air Edge Gateway

KB-2054827

I hope you enjoyed reading this post. Feel free to share this on social media if it is worth sharing. Be sociable 

Category: NSX vCloud Air

About Alex Hunt

Hi All I am Manish Jha. I am currently working in OVH US as Operations Support Engineer (vCloud Air Operations). I have around 7 Years of IT experience and have exposure on VMware vSphere, vCloud Director,vSphere Replication, vRealize Automation, NSX and RHEL. If you find any post informational to you please press like and share it across social media and leave your comments if you want to discuss further on any post. Disclaimer: All the information on this website is published in good faith and for general information purpose only. I don’t make any warranties about the completeness, reliability and accuracy of this information. Any action you take upon the information you find on this blog is strictly at your own risk. The Views and opinions published on this blog are my own and not the opinions of my employer or any of the vendors of the product discussed.