I am using Aws SNS to send notification, and sending notifications to different topics and is working perfectly.
When i publish notification, i got array like
object(Aws\Result)#84 (1) {
["data":"Aws\Result":private]=>
array(2) {
["MessageId"]=>
string(36) "************-7a29-591f-8765-************"
["#metadata"]=>
array(4) {
["statusCode"]=>
int(200)
["effectiveUri"]=>
string(40) "https://sns.ap-southeast-1.amazonaws.com"
["headers"]=>
array(4) {
["x-amzn-requestid"]=>
string(36) "************-b737-5831-abf4-************"
["content-type"]=>
string(8) "text/xml"
["content-length"]=>
string(3) "294"
["date"]=>
string(29) "Fri, 28 Oct 2016 08:59:05 GMT"
}
["transferStats"]=>
array(1) {
["http"]=>
array(1) {
[0]=>
array(0) {}
}
}
}
}
}
I am using php at server side,
But i need to generate a report for each topic separately, that which endpoints (subscriber of topic) get notification and whether notifications are failed, and what is the percentage of successful delivery.
After a lot of research, i found that Aws CloudWatch can do my work, i also searched on stackOverflow for this, and got this answer:
How to confirm delivery status when using amazonSNS mobile push?
I also generated some log in CloudWatch,
By describeLogGroups, i am getting array like
[logGroups] => Array(
[0] => Array
(
[logGroupName] => sns/ap-southeast-1/************/app/GCM/AndroidN
[creationTime] => ************
[retentionInDays] => 30
[metricFilterCount] => 0
[arn] => arn:aws:logs:ap-southeast-1:************:log-group:sns/ap-southeast-1/************/app/GCM/AndroidN:*
[storedBytes] => 3133
)
)
By describeLogStreams, i am getting array like
[logStreams] => Array(
[0] => Array
(
[logStreamName] => 25
[creationTime] => 1477574852344
[firstEventTimestamp] => 1477574831966
[lastEventTimestamp] => 1477574831966
[lastIngestionTime] => 1477574852374
[uploadSequenceToken] => ***********************8
[arn] => arn:aws:logs:ap-southeast-1:*********:log-group:sns/ap-southeast-1/**********/app/GCM/AndroidN:log-stream:25
[storedBytes] => 627
)
)
but confused that how to access it for a particular topic, because in my website i create some topics for group of users (endpoints), and now i want to show for every topic how much notification sent/failed to endpoints not to topic,
Thanks in Anticipants.
Related
I have seen the posts on StackOverflow with similar issues as mine, but none of them helped me resolve the issue. This is why I am creating a new post.
When I first set AWS SNS up, I tested sending SMS using the online console, it worked!
Then I wrote PHP code to send a sample message. I got some errors but was able to resolve them easily. However, when I got a success response, the message was not received at all.
I thought it is a Limitation issue. So I contacted AWS and increased my limit to 20US/month. I updated the preferences, but still the same result. I get a success response, the dashboard shows that a message was sent successfully (although it takes time to update the number of messages sent). But the message is not received.
Here is my code for reference:
<?php
require './aws/aws-autoloader.php';
use Aws\Sns\SnsClient;
use Aws\Exception\AwsException;
$sdk = new SnsClient([
'region' => 'us-east-1',
'version' => 'latest',
'credentials' => [
'key' => 'XXXXXXXXXXXXXXXXXXX',
'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
]
]);
try {
$result = $sdk->publish([
'Message' => 'Reminder - You are scheduled for a session on 2020-05-20 at 4:30 PM',
'MessageStructure' => 'String',
'PhoneNumber' => '+1XXX789XXXX',
'MessageAttributes' => [
'AWS.SNS.SMS.SenderID' => [
'DataType' => 'String',
'StringValue' => 'MyName'
],
'AWS.SNS.SMS.SMSType' => [
'DataType' => 'String',
'StringValue' => 'Transactional'
]
]
]);
var_dump($result);
echo "\n";
} catch (AwsException $e) {
// output error message if fails
var_dump($e->getMessage());
}
And here is the result object:
object(Aws\Result)#119 (2) {
["data":"Aws\Result":private]=>
array(2) {
["MessageId"]=>
string(36) "8cf11950-cdb0-5503-9b69-4e6e9b61eaba"
["#metadata"]=>
array(4) {
["statusCode"]=>
int(200)
["effectiveUri"]=>
string(35) "https://sns.us-east-1.amazonaws.com"
["headers"]=>
array(4) {
["x-amzn-requestid"]=>
string(36) "0488b803-8776-57bc-b9a9-ef3dd1a71805"
["content-type"]=>
string(8) "text/xml"
["content-length"]=>
string(3) "294"
["date"]=>
string(29) "Tue, 19 May 2020 21:50:09 GMT"
}
["transferStats"]=>
array(1) {
["http"]=>
array(1) {
[0]=>
array(0) {
}
}
}
}
}
["monitoringEvents":"Aws\Result":private]=>
array(0) {
}
}
I am out of ideas. Not sure how to resolve this issue. Any help would be appreciated.
Thanks,
I believe by SMS's nature it can fail from time to time.
By my own observation, AWS employ some regional SMS providers that will help them send the SMS to your carriers.
Sometimes the SMS provider fails to send. Sometimes they are rejected by the receiving carrier.
At the moment, we have no way to be sure if It fails ( and react on this situation ) If the SMS is critical to your business, I suggest using another SMS service in conjunction with AWS.
My goal is to create a basic CloudFront distribution using the Paws sdk, and as of yet I have been unable to get past an error 400 with the following configuration:
use Paws;
use Data::Printer;
my $cloudfront = Paws->service('CloudFront');
my $CreateDistributionResult = $cloudfront->CreateDistribution(
DistributionConfig => {
CallerReference => "1578211502",
Origins => {
Quantity => 1,
Items => [{
DomainName => "foo.s3-website-ap-southeast-2.amazonaws.com",
Id => 'S3-Website-foo.s3-website-ap-southeast-2.amazonaws.com'}]
},
DefaultCacheBehavior => {
ForwardedValues => {
Cookies => {Forward => 'none'},
QueryString => 0
},
TargetOriginId => 'S3-Website-foo.s3-website-ap-southeast-2.amazonaws.com',
TrustedSigners => {
Enabled => 0,
Quantity => 0
},
ViewerProtocolPolicy => 'redirect-to-https',
MinTTL => 0
},
Comment => "",
Enabled => 1
});
p $CreateDistributionResult;
The above is the complete set of only the required fields as defined in the api documentation here and here. However, when I run the above it crashes with the following:
[foo#bar~]# perl aws.pl
Paws::CloudFront is not stable / supported / entirely developed at /root/perl5/lib/perl5/Paws/CloudFront.pm line 2.
Bad Request
Trace begun at /root/perl5/lib/perl5/Paws/Net/RestXMLResponse.pm line 24
Paws::Net::RestXMLResponse::process('Paws::Net::RestXMLResponse=HASH(0x2f275b8)', 'Paws::CloudFront::CreateDistribution=HASH(0x2fbe6e0)', 'Paws::Net::APIResponse=HASH(0x30c0ec0)') called at /root/perl5/lib/perl5/Paws/Net/Caller.pm line 46
Paws::Net::Caller::caller_to_response('Paws::Net::Caller=HASH(0x16d7bb8)', 'Paws::CloudFront=HASH(0x2a615f8)', 'Paws::CloudFront::CreateDistribution=HASH(0x2fbe6e0)', 'Paws::Net::APIResponse=HASH(0x30c0ec0)') called at /root/perl5/lib/perl5/Paws/Net/RetryCallerRole.pm line 19
Paws::Net::RetryCallerRole::do_call('Paws::Net::Caller=HASH(0x16d7bb8)', 'Paws::CloudFront=HASH(0x2a615f8)', 'Paws::CloudFront::CreateDistribution=HASH(0x2fbe6e0)') called at /root/perl5/lib/perl5/Paws/CloudFront.pm line 49
Paws::CloudFront::CreateDistribution('Paws::CloudFront=HASH(0x2a615f8)', 'DistributionConfig', 'HASH(0x2f9c500)') called at aws.pl line 6
What is a correct minimal call that would work here?
you don't have anything in the comment argument. Please try passing value there.
AWS is a bit stingy with these kinds of things. Also please let me know if that fixes the issue or not.
Attempting to get cloudtrail logs of multiple aws accounts from s3 into elasticsearch and things appear to be working on and off until now where everything ground to halt. and error show is shown below
[2018-10-16T21:33:42,096][ERROR][logstash.outputs.elasticsearch] Attempted to send a bulk request to elasticsearch, but no there are no living connections in the connection pool. Perhaps Elasticsearch is unreachable or down? {:error_message=>"No Available connections", :class=>"LogStash::Outputs::ElasticSearch::HttpClient::Pool::NoConnectionAvailableError", :will_retry_in_seconds=>8}
[2018-10-16T21:33:44,406][INFO ][logstash.outputs.elasticsearch] Running health check to see if an Elasticsearch connection is working {:healthcheck_url=>https://vpc-sec-dummytext.eu-west-1.es.amazonaws.com:443/, :path=>"/"}
[2018-10-16T21:33:44,430][WARN ][logstash.outputs.elasticsearch] Restored connection to ES instance {:url=>"https://vpc-sec-dummytext.eu-west-1.es.amazonaws.com:443/"}
[2018-10-16T21:33:51,426][ERROR][logstash.outputs.elasticsearch] Encountered a retryable error. Will Retry with exponential backoff {:code=>413, :url=>"https://vpc-sec-dummytext.eu-west-1.es.amazonaws.com:443/_bulk"}
Also here is my logstash config as am using logstash to do ingestion
```
input {
s3 {
bucket => "dummy-s3"
region => "eu-west-1"
type => "cloudtrail"
sincedb_path => "/tmp/logstash/cloudtrail"
exclude_pattern => "/CloudTrail-Digest/"
interval => 120
codec => "json"
}
}
filter {
if [type] == "cloudtrail" {
json {
source => "message"
}
split {
field => "Records"
add_tag => "splitted"
}
if ("splitted" in [tags]) {
date {
match => ["eventTime", "ISO8601"]
remove_tag => ["splitted"]
remove_field => ["timestamp"]
}
}
geoip {
source => "[Records][sourceIPAddress]"
target => "geoip"
add_tag => ["cloudtrail-geoip"]
}
mutate {
gsub => [
"eventSource", "\.amazonaws\.com$", "",
"apiVersion", "_", "-"
]
}
}
}
output {
elasticsearch {
hosts => ["vpc-sec-dummytext.eu-west-1.es.amazonaws.com:443"]
ssl => true
index => "cloudtrail-%{+YYYY.MM.dd}"
doc_as_upsert => true
template_overwrite => true
}
stdout {
codec => rubydebug
}
}
}
When log-stash start or restarted from ubuntu ec2 logs as ingested for a few minutes then stops
Any help will really be appreciated.
I'm trying to consume the OTRS generic interface. The rest service is created by the import functionallity. I found the files needed for import here Consuming OTRS TicketConnector from .NET apps
My problem is when I try to consume the interface for example with a curl command
curl http://<user>:<password>#<server-ip>:<port>/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket/<Ticket-id> -X GET
The result of the command is
{"Error":{"ErrorCode":"TicketGet.AuthFail","ErrorMessage":"TicketGet: Authorization failing!"}}
I tried every user/password combination that makes sense to me. I tried the otrs admin account, agent account, customer account, root account of the server, EVERYTHING! I can't find a information in the docs that states wich account type is needed.
Here are some information that are printed out by the webservice debugger
Communication sequence started
$VAR1 = {
'DOCUMENT_ROOT' => '/srv/www/htdocs',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'HTTP_ACCEPT' => '*/*',
'HTTP_HOST' => '<server-name>',
'HTTP_USER_AGENT' => 'curl/7.39.0',
'MOD_PERL' => 'mod_perl/2.0.4',
'MOD_PERL_API_VERSION' => '2',
'PATH' => '/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin',
'PATH_INFO' => '/Webservice/GenericTicketConnectorREST/Ticket/<ticket-id>',
'PATH_TRANSLATED' => '/srv/www/htdocs/Webservice/GenericTicketConnectorREST/Ticket/<ticket-id>',
'QUERY_STRING' => '',
'REMOTE_ADDR' => '<server-ip>',
'REMOTE_PORT' => '56065',
'REQUEST_METHOD' => 'GET',
'REQUEST_URI' => '/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket/<ticket-id>',
'SCRIPT_FILENAME' => '/opt/otrs/bin/cgi-bin/nph-genericinterface.pl',
'SCRIPT_NAME' => '/otrs/nph-genericinterface.pl',
'SERVER_ADDR' => '<server-ip>',
'SERVER_ADMIN' => '<admin-account>',
'SERVER_NAME' => '<server-name>',
'SERVER_PORT' => '80',
'SERVER_PROTOCOL' => 'HTTP/1.1',
'SERVER_SIGNATURE' => '<address>Apache/2.2.12 (Linux/SUSE) Server at <server-name> Port 80</address>
',
'SERVER_SOFTWARE' => 'Apache/2.2.12 (Linux/SUSE)'
};
Deteced operation TicketGet
No data provided
Incoming data before mapping
$VAR1 = {
'RequestMethod' => 'GET',
'TicketID' => '<ticket-id>'
};
TicketGet.AuthFail
TicketGet: Authorization failing!
Outgoing data before mapping
$VAR1 = {
'Error' => {
'ErrorCode' => 'TicketGet.AuthFail',
'ErrorMessage' => 'TicketGet: Authorization failing!'
}
};
Long story short: what type of authentication or user type otrs expects to access the generic interface?
In found my mistake. The way I passed the login credentials to the service was wrong.
In my case the user is a agent user.
Here is a working curl command for my service:
curl http://<server-ip>:<port>/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket/<ticket-id>?UserLogin=<username>\&Password=<password> -X GET
Realtime updates are kicking my ass! I have my entire fb app working except for this one area and I'm just not sure what I'm doing wrong.
My app is approved using these permissions:
"scope" => "offline_access,publish_stream,read_stream,user_location,user_status",
Next, I subscribe using these settings:
$subscribe = array( 'access_token'=> substr($my_access_token,13),
'object' => 'user',
'fields' => 'name,feed',
'callback_url' => $fbconfig['callback'],
'verify_token' => $fbconfig['secret']);
Via my app I post a status update on behaf of Bill Smith (userid: 000041143) and
that appears on Bill Smith's wall just fine. Next, using a an account for John
Doe (userid: 000004842 which has NOT authorized my app) I comment on the status post
made on Bill Smith's wall and this triggers the callback but what I'm getting (see below)
is an entry telling me that John Doe's wall has changed and no mention of Bill Smiths
wall is ever made.
Here's the notification given in the callback:
updates = Array
(
[object] => user
[entry] => Array
(
[0] => Array
(
[uid] => 000004842
[id] => 000004842
[time] => 1325101631
[changed_fields] => Array
(
[0] => feed
)
)
[1] => Array
(
[uid] => 000004842
[id] => 000004842
[time] => 1325101651
[changed_fields] => Array
(
[0] => feed
)
)
)
)
As you can see, this is not a notification that a comment has been made to Bill Smiths wall but that one has been made to John Doe's... I dont get this... I must be doing SOMETHING wrong!
I had similar issues before with photo IDs turning up 'wrong', the issue occurred because I was treating it as an INT but PHP was truncating it because it was too big, I had to treat it as a string. Could this be your issue perhaps?