Amazon-Cloudwatch [SOLVED]: Amazon Cloudwatch Logs from External Website

Amazon-Cloudwatch [SOLVED]: Amazon Cloudwatch Logs from External Website

Home Forums Amazon Web Services Amazon Cloudwatch Amazon-Cloudwatch [SOLVED]: Amazon Cloudwatch Logs from External Website

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #197294

    Cloudy Point
    Keymaster

    QuestionQuestion

    I’m a bit of a AWS newbie so forgive me if this is a stupid question. We have a legacy Classic ASP website (not hosted at Amazon) and I wanted to know if its possible to utilize Amazon Cloudwatch for custom logging. I know we could use a site like Loggly or Sumo Logic but their retention policies are a little short and the pricing a bit too expensive for our small site. But essentially, I’m trying to recreate their functionality in AWS.

    There is quite a bit of detail on how to log from various Amazon services (EC2, etc…) but I’m not finding much on using Cloudwatch from a non-Amazon hosted site

    Basically, I want to SERVERXMLHTTP POST a json log string from our Classic ASP site to Cloudwatch. However, I’m struggling to find the right endpoint and how to post to a particular Log Group that I’ve created. Do I use

    https://monitoring.us-west-1.amazonaws.com/doc/2010-08-01/?Action=PutMetricData
    

    or

    https://logs.us-west-1.amazonaws.com/doc/2010-08-01/?Action=PutMetricData
    

    to try to post json like this

     [
       {
         "MetricName": "404 Error",
         "Timestamp": "Wednesday, June 12, 2013 8:28:20 PM",
         "Value": "http://example.com/badpage.asp",
         "Unit": "Count"
       }
     ]
    

    Also, how do I post the json to a particular log group / log stream that I’ve created? Do I authenticate with some sort of

    xxx.setRequestHeader "Authorization", "Basic " & [auth credentials] 
    

    ?

    Thanks for any help!

    #197295

    Cloudy Point
    Keymaster

    Accepted AnswerAnswer

    You can find the list of AWS endpoints here: http://docs.aws.amazon.com/general/latest/gr/rande.html

    logs.us-west-1.amazonaws.com

    The authentication is done with signed requests: http://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/making-api-requests.html

    When you send HTTP requests to AWS, you sign the requests so that AWS can identify who sent them. You sign requests with your AWS access key, which consists of an access key ID and secret access key.

    And about the specific API call to put the log probably is PutLogEvents: http://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html

    Uploads a batch of log events to the specified log stream.

    And remember there’s a SDK for the browser: https://aws.amazon.com/es/sdk-for-browser/

    Source: https://stackoverflow.com/questions/46415846/amazon-cloudwatch-logs-from-external-website
    Author: Diego F. Durán
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.