Datasource for API Gateway Resources behind a stage

Recommended Posts

I have been using a custom datasource to collect the metrics for each resource and method (excluding OPTIONS) behind a API Gateway stage.  It has been extremely useful in our production environments.  I would share the datasource via the Exchange, but the discovery method I'm using will not be universal, so I think it would be best if that discovery were to work natively.  If possible, could we please have a discovery method for AWS API Gateway Resources by Stage?  

*Something to note - This has the potential to discover quite a few resources and thus, create a substantial number of cloudwatch calls which might hit customer billing.  For this reason, I added a custom property ##APIGW.stages## so that I could plug in the specific stages I wish to monitor instead of having each one automatically discovered.  The Applies To looks like this: == "AWS/APIGateway" && apigw.stages

Autodiscovery is currently written in PowerShell (hence why not everyone can take advantage of it)

$apigwID = '';
$region = ''
$stages = '##APIGW.Stages##';

$resources = Get-AGResourceList -RestApiId $apigwID -region $region

$stages.split(' ') | %{
    $stage = $_
    $resources | %{
        if($_.ResourceMethods) {
            $path = $_.Path
            $_.ResourceMethods.Keys | where{$_ -notmatch 'OPTIONS'} | %{
                $wildvalue = "Stage=$stage>Resource=$Path>Method=$_"
                Write-Host "$wildvalue##${Stage}: $_ $Path######auto.stage=$stage"



Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.