【发布时间】:2020-08-16 10:22:45
【问题描述】:
我很仔细地看了monitoring API。据我所知,可以使用 gcloud 创建监控策略并编辑策略 (Using Aleert API)。
然而,从一方面来看,gcloud 似乎只能创建和编辑策略选项,而不能读取此类策略的结果。从这个页面我读到了这个选项:
Creating new policies
Deleting existing policies
Retrieving specific policies
Retrieving all policies
Modifying existing policies
另一方面,我从result of a failed request读到
Summary of the result of a failed request to write data to a time series.
所以它在我脑海中敲响了警钟,我确实可以获得一个结果列表,例如在某个时期内所有失败的写入请求。但是怎么做呢?
拜托,我的直截了当的问题是:我能否以某种方式监听警报事件或获取警报结果列表抛出Monitoring API v3?。
我看到 tag_firestore_instance 与 firestore 有某种关联,但如何使用它以及我可以搜索哪些信息?我在任何地方都找不到如何使用它。可能是常见的获取(例如 Postman/curl)或来自 gcloud shell。
PS.:这个问题最初是在Google Group 发布的,但我很高兴在这里问。
*** 在 Alex 的建议下编辑
我有一个 Angular 页面正在监听我的 Firestore 数据库中的文档
export class AppComponent {
public transfers: Observable<any[]>;
transferCollectionRef: AngularFirestoreCollection<any>;
constructor(public auth: AngularFireAuth, public db: AngularFirestore) {
this.listenSingleTransferWithToken();
}
async listenSingleTransferWithToken() {
await this.auth.signInWithCustomToken("eyJ ... CVg");
this.transferCollectionRef = this.db.collection<any>('transfer', ref => ref.where("id", "==", "1"));
this.transfers = this.transferCollectionRef.snapshotChanges().map(actions => {
return actions.map(action => {
const data = action.payload.doc.data();
const id = action.payload.doc.id;
return { id, ...data };
});
});
}
}
所以,我知道至少有一个读者可以返回
name: projects/firetestjimis
filter: metric.type = "firestore.googleapis.com/document/read_count"
interval.endTime: 2020-05-07T15:09:17Z
【问题讨论】:
标签: google-cloud-platform google-cloud-firestore google-cloud-datastore stackdriver google-cloud-shell