Am I getting hacked ? Cloud Firestore huge pick gap of traffic, with no explanation - google-cloud-firestore

I'm currently facing to a huge pick of Read on Cloud Firestore and no way to go up stream to find the issue. I saw first this increase on Cloudflare. From 1million request to 175millions in 3 days with no correlation with user activity.
Cloudflare Dashboard before
Cloudflare Dashboard after
Diving into Statistics from GCP and Firebase is even more confusing had they are reflecting different reality.
GCP Dashboard Cloud Firestore Read and Write
Firebase Dashboard Firestore Read and Write
I verified if it was correlated to a new development or new security rule, but nothing.
I was thinking for a time about an hacking but Write seems to follow Read, but sure of nothing.
Can anyone had a previous experience like that, or a hint of where to find more infos on GCP.
Thanks for reading guys

Related

How To Get Email Notification when Firebase Cloud Function Exceeds Certain Invocation Threshold

I am developing a flutter application and using Firebase Cloud Function as a backend service. Due to a bug, my Flutter application was making infinite request to an HTTP cloud function. The requests invocation would stop when I would dispose the Screen. I was able to detect this bug due to the print logs.
I have resolved the issue but this led me to the search of a service or a way by which I can be notified when my Cloud Function is being called too many time in a certain period of time, For example, if my Cloud Function is called 100 times in under 20 seconds then I should be notified via an Email so that I can fix the issue. The application is currently in development so I want to keep the threshold as low as possible so that I can detect an issue as quickly as possible to avoid expensive costing.
I have done research of my own but I cannot seem to find a proper answer. I have found out about Google Cloud Monitoring but I don't understand it properly. The documentation is quite complex, I cannot find any tutorials on youtube or any answers on SO.
I tried to make an alert policy in the Google Cloud Monitoring and tried the 'metrics' but it did not work because I do not have good understanding of the plateform.
Can anyone help me in solving this issue. I would like a step by step solution to the problem.

Google Cloud Spanner real time Change Data Capture to PubSub/Kafka through Cloud Data Fusion or Others

I would like to achieve a real time change data capture (log-based preferred) pipeline from Google Cloud Spanner to PubSub/Kafka for my downstream real time applications. Could you please let me know if there is a great and cost-effective way to achieve that? I will appreciate any advice and recommendations.
In addition, for Cloud Data Fusion from google, I noticed that it could achieve real time from mysql/postgresql to cloud spanner, but I did not find the way go from cloud spanner to pubsub/kafka in real time.
Also, I found another two ways, which to be listed here for any comments or suggestions.
Use Debezium, a log-based change data capture Kafka connector from the link https://cloud.google.com/architecture/capturing-change-logs-with-debezium#deploying_debezium_on_gke_on_google_cloud
Create a polling service (which may miss some data) to poll data from cloud spanner from the link: https://cloud.google.com/architecture/deploying-event-sourced-systems-with-cloud-spanner
If you have any suggestion or comment on this, I will be really grateful.
There's a open source implementation of a polling service for Cloud Spanner that can also automatically push changes to PubSub here: https://github.com/cloudspannerecosystem/spanner-change-watcher
It is however not log-based. It has some inherent limitations:
It can miss updates if the same record is updated twice within the polling interval. In that case, only the last value will be reported.
It only supports soft deletes.
You could have a look at the samples to see if it is something that might suit your needs at least to some degree: https://github.com/cloudspannerecosystem/spanner-change-watcher/tree/master/samples
Cloud Spanner has a new feature called Change Streams that would allow building a downstream pipeline from Spanner to PubSub/Kafka.
At this time, there's not a pre-packaged Spanner to PubSub/Kafka connector.
The way to read change streams currently is to use the SpannerIO Apache Beam connector that would allow building the pipeline with Dataflow, or also directly querying the API.
Disclaimer: I'm a Developer Advocate that works with the Cloud Spanner team.

Audio streaming from Google Cloud Storage and CDNs - costs

So I'm making an app that involves streaming audio(radio-like) from the Google Cloud Storage and was looking into the costs. It seems it would be much too expensive as is.
e.g. Lets say I have 10MB audio files, a user listens to 20 files a day and I have 2000 active users. That's 400GBs or $48/day. i.e. ~$1440/month just for that.
I then looked into putting a CDN in front of it, to minimize direct reads from the Storage. Now initially that made sense to me. The CDN would cache the audio files and the clients would be getting the files from the cache most of the time. However, as I was looking at Fastly's pricing (Fastly is a Google partner and seems like a good fit) I noticed that they seem to be pricing bandwidth usage to their cache at the exact same rate as Google cloud does ($0.12/GB). So unless I'm reading this wrong, putting up the CDN would not save me ANY money. Now I get that there are other reasons why putting a CDN in front of it could be a good idea, but am I really reading this right?
Also, if you have any other tips on how I should set this up, I'm all ears.
Estimating the invoice of such a service is a complex matter. To get an informed answer and tips regarding possible implementation paths I would suggest reaching out to a GCP Sales representative. Similarly you should contact the Fastly team to get a precise picture of their pricing model.
Moreover, any estimate we could make here would be outdated as soon as any of the respective pricing model changes, which would invalidate the answer and probably drive future readers to wrong conclusions.

My firestore account has A LOT of reads. How can I monitore from where?

My page is quite small it has around 300-1000 visits each day. But at some point I started to accumulate HUGE firestore read requests:
Till the 8th date it was somewhere around 50K each day. I am pushing new code all the time so I'm not sure what I did. Looking at the page I don't see anything out of ordinary. Is there some sort of log in google or firestore I could look at?
The Firebase documentation indicates that each time you create a project, it also creates a project in Google Cloud Platform, therefore you can track daily Cloud Firestore usage like writes, deletes, etc. This usage information is shown in the GCP's console in the App Engine Quotas page .You can see more details in the link. https://firebase.google.com/docs/firestore/monitor-usage#google-cloud-platform-console
There is currently no way to track the origin of reads. What you're looking at now is the best indicator you have available.
Bear in mind that the Firebase and Cloud consoles show updates to documents in real time, and each document update costs a read. If you leave the console open on a busy collection, it will rack up reads.

Flutter and Firestore: debug usage

Is there a way to easily debug the read and write requests a Flutter app makes to Firestore? I'm getting a high number of reads, but battling to find where those are originating from in the app.
Have you tried using the StackDriver logging User Interface?
It offers plenty of log analysis tools that you can use to monitor resources that are writing into your Firestore DataBase.
You can read more about this here [1].
Once you have created logs-based metrics, you can create charts and alerts on said metrics.
[1] https://firebase.google.com/docs/functions/writing-and-viewing-logs