[英]Azure / Cosmos DB is counting requests (RUs) I didn't make
I'm working on a simple Xamarin app, that needs to connect to and validate login information against a Cosmos DB collection of users. 我正在开发一个简单的Xamarin应用程序,该应用程序需要连接到Cosmos DB用户集合并针对其验证登录信息。
My app has had two requests, but the activity in Azure portal is showing many more. 我的应用程序有两个请求,但是Azure门户中的活动显示了更多请求。 Also I only did an "insert" into the azure portal for a single document to test the connection and some basic functionality
另外,我只对一个文档进行了“插入”操作,以测试连接和一些基本功能
What is going on here? 这里发生了什么?
I created the database around 11:00 and this was captured 12:15: 我在11:00左右创建了数据库,并在12:15捕获了该数据库:
Code that is establishing the connection:
建立连接的代码:
public void Start(string ConnectionString = @"mongodb://secrets"){
//ConnectionString = @"mongodb://192.168.0.111:27017"; // Local test mongodb
MongoClientSettings settings = MongoClientSettings.FromUrl(new MongoUrl(ConnectionString));
settings.SslSettings = new SslSettings() { EnabledSslProtocols = SslProtocols.Tls12 };
//var mongoClient = new MongoClient(settings);
CosmosClient = new MongoClient(settings);
CosmosDatabase = CosmosClient.GetDatabase("dbname");
CosmosUsersCollection = CosmosDatabase.GetCollection<BsonDocument>("users");
Ready = true;}
Code for checking login: 用于检查登录的代码:
public async Task<string> LoginAsync(string name, string password){
if (!Ready) { Start(); }
var builder = Builders<BsonDocument>.Filter;
var filter = builder.Eq("nick", name) & builder.Eq("password", password);
string output;
try
{
var var1 = await CosmosUsersCollection.Find(filter).FirstAsync();
Console.WriteLine("LOGIN RESPONSE: " + var1);
output = var1.ToJson();
}
catch (Exception ex)
{
Console.WriteLine("LOGIN FAILED: " + ex.Message);
output = ex.Message;
throw;
}
return output;}
And the data I'm reading from 还有我正在读取的数据
{
"_id" : ObjectId(""),
"nick" : "FRANK_1988",
"password" : "password",
"location" : {
"type" : "Point",
"coordinates" : [
58.2237183172273,
7.98107150169605
]
}
To understand the detail of those requests, you can use Azure Monitor . 要了解这些请求的详细信息,可以使用Azure Monitor 。 Go to the Azure Portal and look for the Monitor service:
转到Azure门户并查找Monitor服务:
Go to Metrics : 转到指标 :
Then find your resource by Subscription, Resource Group and name and select the Mongo Requests metric: 然后按“订阅”,“资源组”和“名称”查找您的资源,然后选择“ Mongo请求数”度量标准:
Finally, Apply a splitting over the Command Name: 最后,对命令名称进行拆分:
Now you should be able to see the detail on each command and which commands are generating those requests. 现在,您应该能够看到每个命令的详细信息以及哪些命令正在生成这些请求。 Keep in mind that not always Commands = RU consumption, there are some commands that do not yield consumed RUs (you can see the consumed RUs of a command with
GetLastRequestStatistics
. 请记住,并非总是Commands = RU消耗,有些命令并不产生消耗的RU(您可以使用
GetLastRequestStatistics
查看命令消耗的RU。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.