diff --git a/api/managementpb/checks.pb.go b/api/managementpb/checks.pb.go index ead9da805a..b86b939868 100644 --- a/api/managementpb/checks.pb.go +++ b/api/managementpb/checks.pb.go @@ -1654,7 +1654,7 @@ var file_managementpb_checks_proto_rawDesc = []byte{ 0x41, 0x4d, 0x49, 0x4c, 0x59, 0x5f, 0x50, 0x4f, 0x53, 0x54, 0x47, 0x52, 0x45, 0x53, 0x51, 0x4c, 0x10, 0x02, 0x12, 0x20, 0x0a, 0x1c, 0x41, 0x44, 0x56, 0x49, 0x53, 0x4f, 0x52, 0x5f, 0x43, 0x48, 0x45, 0x43, 0x4b, 0x5f, 0x46, 0x41, 0x4d, 0x49, 0x4c, 0x59, 0x5f, 0x4d, 0x4f, 0x4e, 0x47, 0x4f, - 0x44, 0x42, 0x10, 0x03, 0x32, 0xe8, 0x0f, 0x0a, 0x0e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, + 0x44, 0x42, 0x10, 0x03, 0x32, 0xef, 0x0f, 0x0a, 0x0e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x12, 0x89, 0x02, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x25, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, @@ -1686,111 +1686,111 @@ var file_managementpb_checks_proto_rawDesc = []byte{ 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2f, 0x3a, 0x01, 0x2a, 0x22, 0x2a, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x2f, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x43, - 0x68, 0x65, 0x63, 0x6b, 0x73, 0x12, 0xe7, 0x01, 0x0a, 0x10, 0x54, 0x6f, 0x67, 0x67, 0x6c, 0x65, + 0x68, 0x65, 0x63, 0x6b, 0x73, 0x12, 0xec, 0x01, 0x0a, 0x10, 0x54, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, 0x23, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x54, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x54, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x87, 0x01, 0x92, 0x41, 0x4b, 0x12, 0x12, 0x54, 0x6f, 0x67, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x8c, 0x01, 0x92, 0x41, 0x4d, 0x12, 0x12, 0x54, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x20, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x20, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x1a, 0x35, 0x53, 0x69, 0x6c, 0x65, 0x6e, 0x63, 0x65, 0x2f, 0x55, 0x6e, 0x73, 0x69, 0x6c, 0x65, 0x6e, 0x63, 0x65, 0x20, 0x61, 0x6c, 0x65, 0x72, 0x74, 0x73, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x61, 0x20, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x63, 0x20, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x20, 0x72, - 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x33, 0x3a, 0x01, 0x2a, 0x22, - 0x2e, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2f, - 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x2f, 0x54, - 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x6c, 0x65, 0x72, 0x74, 0x12, - 0x86, 0x02, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, - 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x12, 0x2a, 0x2e, 0x6d, 0x61, - 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x63, 0x75, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x58, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x33, 0x3a, 0x01, + 0x2a, 0x22, 0x2e, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, + 0x74, 0x2f, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, + 0x2f, 0x54, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x41, 0x6c, 0x65, 0x72, + 0x74, 0x88, 0x02, 0x01, 0x12, 0x88, 0x02, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, - 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, - 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x91, 0x01, 0x92, 0x41, 0x53, 0x12, 0x1a, 0x47, 0x65, 0x74, 0x20, - 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x20, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x20, 0x52, - 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x1a, 0x35, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x73, 0x20, - 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x20, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x20, - 0x54, 0x6f, 0x6f, 0x6c, 0x27, 0x73, 0x20, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x20, 0x63, 0x68, - 0x65, 0x63, 0x6b, 0x73, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x2e, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x32, 0x3a, 0x01, 0x2a, 0x22, 0x2d, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, - 0x68, 0x65, 0x63, 0x6b, 0x73, 0x2f, 0x47, 0x65, 0x74, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, - 0x73, 0x75, 0x6c, 0x74, 0x73, 0x88, 0x02, 0x01, 0x12, 0xc9, 0x02, 0x0a, 0x13, 0x53, 0x74, 0x61, + 0x12, 0x2a, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x47, 0x65, + 0x74, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, + 0x73, 0x75, 0x6c, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x6d, + 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x63, + 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x93, 0x01, 0x92, 0x41, 0x55, 0x12, + 0x1a, 0x47, 0x65, 0x74, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x20, 0x43, 0x68, + 0x65, 0x63, 0x6b, 0x20, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x1a, 0x35, 0x52, 0x65, 0x74, + 0x75, 0x72, 0x6e, 0x73, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x20, 0x54, 0x68, + 0x72, 0x65, 0x61, 0x64, 0x20, 0x54, 0x6f, 0x6f, 0x6c, 0x27, 0x73, 0x20, 0x6c, 0x61, 0x74, 0x65, + 0x73, 0x74, 0x20, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x73, 0x2e, 0x58, 0x01, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x32, 0x3a, 0x01, 0x2a, 0x22, 0x2d, 0x2f, + 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x53, 0x65, + 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x2f, 0x47, 0x65, 0x74, + 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x88, 0x02, 0x01, 0x12, + 0xc9, 0x02, 0x0a, 0x13, 0x53, 0x74, 0x61, 0x72, 0x74, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, + 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x12, 0x26, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, + 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, + 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x27, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, - 0x12, 0x26, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x74, - 0x61, 0x72, 0x74, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x53, 0x74, 0x61, 0x72, 0x74, 0x53, 0x65, 0x63, 0x75, 0x72, - 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0xe0, 0x01, 0x92, 0x41, 0xae, 0x01, 0x12, 0x15, 0x53, 0x74, 0x61, 0x72, 0x74, 0x20, - 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x20, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x1a, - 0x94, 0x01, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x73, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, - 0x69, 0x74, 0x79, 0x20, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x20, 0x54, 0x6f, 0x6f, 0x6c, 0x20, - 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, - 0x6e, 0x73, 0x20, 0x77, 0x68, 0x65, 0x6e, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x63, 0x68, 0x65, 0x63, - 0x6b, 0x73, 0x20, 0x61, 0x72, 0x65, 0x20, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x64, 0x2e, - 0x20, 0x41, 0x6c, 0x6c, 0x20, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x63, - 0x68, 0x65, 0x63, 0x6b, 0x73, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x62, 0x65, 0x20, 0x73, 0x74, - 0x61, 0x72, 0x74, 0x65, 0x64, 0x20, 0x69, 0x66, 0x20, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x20, 0x6e, - 0x61, 0x6d, 0x65, 0x73, 0x20, 0x61, 0x72, 0x65, 0x6e, 0x27, 0x74, 0x20, 0x73, 0x70, 0x65, 0x63, - 0x69, 0x66, 0x69, 0x65, 0x64, 0x2e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x28, 0x3a, 0x01, 0x2a, 0x22, - 0x23, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2f, - 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x2f, 0x53, - 0x74, 0x61, 0x72, 0x74, 0x12, 0xdb, 0x01, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x63, - 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x12, 0x25, 0x2e, 0x6d, 0x61, - 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x63, - 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xe0, 0x01, 0x92, 0x41, 0xae, 0x01, 0x12, + 0x15, 0x53, 0x74, 0x61, 0x72, 0x74, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x20, + 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x1a, 0x94, 0x01, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, + 0x73, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x20, 0x54, 0x68, 0x72, 0x65, 0x61, + 0x64, 0x20, 0x54, 0x6f, 0x6f, 0x6c, 0x20, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x20, 0x61, 0x6e, + 0x64, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x73, 0x20, 0x77, 0x68, 0x65, 0x6e, 0x20, 0x61, + 0x6c, 0x6c, 0x20, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x20, 0x61, 0x72, 0x65, 0x20, 0x65, 0x78, + 0x65, 0x63, 0x75, 0x74, 0x65, 0x64, 0x2e, 0x20, 0x41, 0x6c, 0x6c, 0x20, 0x61, 0x76, 0x61, 0x69, + 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x20, 0x77, 0x69, 0x6c, + 0x6c, 0x20, 0x62, 0x65, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x20, 0x69, 0x66, 0x20, + 0x63, 0x68, 0x65, 0x63, 0x6b, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x20, 0x61, 0x72, 0x65, 0x6e, + 0x27, 0x74, 0x20, 0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x2e, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x28, 0x3a, 0x01, 0x2a, 0x22, 0x23, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x6e, 0x61, + 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, + 0x68, 0x65, 0x63, 0x6b, 0x73, 0x2f, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0xdb, 0x01, 0x0a, 0x12, + 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, + 0x6b, 0x73, 0x12, 0x25, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, - 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x76, 0x92, 0x41, 0x46, 0x12, - 0x13, 0x4c, 0x69, 0x73, 0x74, 0x20, 0x61, 0x64, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x20, 0x63, 0x68, - 0x65, 0x63, 0x6b, 0x73, 0x1a, 0x2f, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x73, 0x20, 0x61, 0x20, - 0x6c, 0x69, 0x73, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x20, 0x61, - 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, - 0x75, 0x73, 0x65, 0x72, 0x2e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x27, 0x3a, 0x01, 0x2a, 0x22, 0x22, - 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x53, - 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x2f, 0x4c, 0x69, - 0x73, 0x74, 0x12, 0xbf, 0x01, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x64, 0x76, 0x69, 0x73, - 0x6f, 0x72, 0x73, 0x12, 0x1f, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, - 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x64, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, - 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x64, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x6c, 0x92, 0x41, 0x42, 0x12, 0x0d, 0x4c, 0x69, 0x73, - 0x74, 0x20, 0x61, 0x64, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x73, 0x1a, 0x31, 0x52, 0x65, 0x74, 0x75, - 0x72, 0x6e, 0x73, 0x20, 0x61, 0x20, 0x6c, 0x69, 0x73, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x61, 0x64, - 0x76, 0x69, 0x73, 0x6f, 0x72, 0x73, 0x20, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, - 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x21, 0x3a, 0x01, 0x2a, 0x22, 0x1c, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x6e, 0x61, - 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x41, 0x64, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x73, 0x2f, - 0x4c, 0x69, 0x73, 0x74, 0x12, 0x88, 0x02, 0x0a, 0x14, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x53, - 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x12, 0x27, 0x2e, + 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x6d, 0x61, 0x6e, 0x61, + 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x63, 0x75, 0x72, + 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x76, 0x92, 0x41, 0x46, 0x12, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x20, 0x61, 0x64, 0x76, + 0x69, 0x73, 0x6f, 0x72, 0x20, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x1a, 0x2f, 0x52, 0x65, 0x74, + 0x75, 0x72, 0x6e, 0x73, 0x20, 0x61, 0x20, 0x6c, 0x69, 0x73, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x63, + 0x68, 0x65, 0x63, 0x6b, 0x73, 0x20, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x20, + 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x82, 0xd3, 0xe4, 0x93, + 0x02, 0x27, 0x3a, 0x01, 0x2a, 0x22, 0x22, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, + 0x65, 0x63, 0x6b, 0x73, 0x2f, 0x4c, 0x69, 0x73, 0x74, 0x12, 0xbf, 0x01, 0x0a, 0x0c, 0x4c, 0x69, + 0x73, 0x74, 0x41, 0x64, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x73, 0x12, 0x1f, 0x2e, 0x6d, 0x61, 0x6e, + 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x64, 0x76, 0x69, + 0x73, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x6d, 0x61, + 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x64, 0x76, + 0x69, 0x73, 0x6f, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x6c, 0x92, + 0x41, 0x42, 0x12, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x20, 0x61, 0x64, 0x76, 0x69, 0x73, 0x6f, 0x72, + 0x73, 0x1a, 0x31, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x73, 0x20, 0x61, 0x20, 0x6c, 0x69, 0x73, + 0x74, 0x20, 0x6f, 0x66, 0x20, 0x61, 0x64, 0x76, 0x69, 0x73, 0x6f, 0x72, 0x73, 0x20, 0x61, 0x76, + 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x75, + 0x73, 0x65, 0x72, 0x2e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x21, 0x3a, 0x01, 0x2a, 0x22, 0x1c, 0x2f, + 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x41, 0x64, + 0x76, 0x69, 0x73, 0x6f, 0x72, 0x73, 0x2f, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x88, 0x02, 0x0a, 0x14, + 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, + 0x65, 0x63, 0x6b, 0x73, 0x12, 0x27, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, + 0x74, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, + 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, - 0x65, 0x6e, 0x74, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, - 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x9c, 0x01, 0x92, 0x41, 0x6a, 0x12, 0x16, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x20, 0x53, - 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x20, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x1a, 0x50, - 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x2f, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x73, - 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x20, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, - 0x20, 0x54, 0x6f, 0x6f, 0x6c, 0x20, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x20, 0x6f, 0x72, 0x20, - 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x20, 0x74, 0x68, 0x65, 0x69, 0x72, 0x20, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x20, 0x62, 0x79, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x2e, - 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x29, 0x3a, 0x01, 0x2a, 0x22, 0x24, 0x2f, 0x76, 0x31, 0x2f, 0x6d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, - 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x2f, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x42, - 0x8e, 0x01, 0x0a, 0x0e, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, - 0x6e, 0x74, 0x42, 0x0b, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x65, - 0x72, 0x63, 0x6f, 0x6e, 0x61, 0x2f, 0x70, 0x6d, 0x6d, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6d, 0x61, - 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x70, 0x62, 0xa2, 0x02, 0x03, 0x4d, 0x58, 0x58, - 0xaa, 0x02, 0x0a, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0xca, 0x02, 0x0a, - 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0xe2, 0x02, 0x16, 0x4d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0xea, 0x02, 0x0a, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x9c, 0x01, 0x92, 0x41, 0x6a, 0x12, 0x16, 0x43, + 0x68, 0x61, 0x6e, 0x67, 0x65, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x20, 0x43, + 0x68, 0x65, 0x63, 0x6b, 0x73, 0x1a, 0x50, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x2f, 0x64, + 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x20, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, + 0x20, 0x54, 0x68, 0x72, 0x65, 0x61, 0x64, 0x20, 0x54, 0x6f, 0x6f, 0x6c, 0x20, 0x63, 0x68, 0x65, + 0x63, 0x6b, 0x73, 0x20, 0x6f, 0x72, 0x20, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x20, 0x74, + 0x68, 0x65, 0x69, 0x72, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x20, 0x62, 0x79, + 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x29, 0x3a, 0x01, 0x2a, + 0x22, 0x24, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, + 0x2f, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x2f, + 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x42, 0x8e, 0x01, 0x0a, 0x0e, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, + 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x0b, 0x43, 0x68, 0x65, 0x63, 0x6b, + 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x65, 0x72, 0x63, 0x6f, 0x6e, 0x61, 0x2f, 0x70, 0x6d, 0x6d, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x70, + 0x62, 0xa2, 0x02, 0x03, 0x4d, 0x58, 0x58, 0xaa, 0x02, 0x0a, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, + 0x6d, 0x65, 0x6e, 0x74, 0xca, 0x02, 0x0a, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, + 0x74, 0xe2, 0x02, 0x16, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x5c, 0x47, + 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0a, 0x4d, 0x61, 0x6e, + 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/managementpb/checks.proto b/api/managementpb/checks.proto index 91bf8e0743..e2d9f82add 100644 --- a/api/managementpb/checks.proto +++ b/api/managementpb/checks.proto @@ -204,6 +204,7 @@ service SecurityChecks { } // ToggleCheckAlert allows to switch alerts state for a check result between "silenced" and "unsilenced". rpc ToggleCheckAlert(ToggleCheckAlertRequest) returns (ToggleCheckAlertResponse) { + option deprecated = true; option (google.api.http) = { post: "/v1/management/SecurityChecks/ToggleCheckAlert" body: "*" @@ -211,6 +212,7 @@ service SecurityChecks { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { summary: "Toggle Check Alert" description: "Silence/Unsilence alerts for a specific check result." + deprecated: true }; } // GetSecurityCheckResults returns Security Thread Tool's latest checks results. @@ -223,6 +225,7 @@ service SecurityChecks { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { summary: "Get Security Check Results" description: "Returns Security Thread Tool's latest checks results." + deprecated: true }; } // StartSecurityChecks executes Security Thread Tool checks and returns when all checks are executed. diff --git a/api/managementpb/checks_grpc.pb.go b/api/managementpb/checks_grpc.pb.go index bfa8496cd4..0408efe0a2 100644 --- a/api/managementpb/checks_grpc.pb.go +++ b/api/managementpb/checks_grpc.pb.go @@ -38,6 +38,7 @@ type SecurityChecksClient interface { ListFailedServices(ctx context.Context, in *ListFailedServicesRequest, opts ...grpc.CallOption) (*ListFailedServicesResponse, error) // GetFailedChecks returns the checks result for a given service. GetFailedChecks(ctx context.Context, in *GetFailedChecksRequest, opts ...grpc.CallOption) (*GetFailedChecksResponse, error) + // Deprecated: Do not use. // ToggleCheckAlert allows to switch alerts state for a check result between "silenced" and "unsilenced". ToggleCheckAlert(ctx context.Context, in *ToggleCheckAlertRequest, opts ...grpc.CallOption) (*ToggleCheckAlertResponse, error) // Deprecated: Do not use. @@ -79,6 +80,7 @@ func (c *securityChecksClient) GetFailedChecks(ctx context.Context, in *GetFaile return out, nil } +// Deprecated: Do not use. func (c *securityChecksClient) ToggleCheckAlert(ctx context.Context, in *ToggleCheckAlertRequest, opts ...grpc.CallOption) (*ToggleCheckAlertResponse, error) { out := new(ToggleCheckAlertResponse) err := c.cc.Invoke(ctx, SecurityChecks_ToggleCheckAlert_FullMethodName, in, out, opts...) @@ -142,6 +144,7 @@ type SecurityChecksServer interface { ListFailedServices(context.Context, *ListFailedServicesRequest) (*ListFailedServicesResponse, error) // GetFailedChecks returns the checks result for a given service. GetFailedChecks(context.Context, *GetFailedChecksRequest) (*GetFailedChecksResponse, error) + // Deprecated: Do not use. // ToggleCheckAlert allows to switch alerts state for a check result between "silenced" and "unsilenced". ToggleCheckAlert(context.Context, *ToggleCheckAlertRequest) (*ToggleCheckAlertResponse, error) // Deprecated: Do not use. diff --git a/api/managementpb/json/managementpb.json b/api/managementpb/json/managementpb.json index 906290de9f..b5c9de7585 100644 --- a/api/managementpb/json/managementpb.json +++ b/api/managementpb/json/managementpb.json @@ -6365,6 +6365,7 @@ ], "summary": "Get Security Check Results", "operationId": "GetSecurityCheckResults", + "deprecated": true, "parameters": [ { "name": "body", @@ -6788,6 +6789,7 @@ ], "summary": "Toggle Check Alert", "operationId": "ToggleCheckAlert", + "deprecated": true, "parameters": [ { "name": "body", diff --git a/api/swagger/swagger-dev.json b/api/swagger/swagger-dev.json index bd44fe8f09..8801f4cba5 100644 --- a/api/swagger/swagger-dev.json +++ b/api/swagger/swagger-dev.json @@ -29902,6 +29902,7 @@ ], "summary": "Get Security Check Results", "operationId": "GetSecurityCheckResults", + "deprecated": true, "parameters": [ { "name": "body", @@ -30325,6 +30326,7 @@ ], "summary": "Toggle Check Alert", "operationId": "ToggleCheckAlert", + "deprecated": true, "parameters": [ { "name": "body", diff --git a/api/swagger/swagger.json b/api/swagger/swagger.json index 48d466adff..f1e0ccb21b 100644 --- a/api/swagger/swagger.json +++ b/api/swagger/swagger.json @@ -20529,6 +20529,7 @@ ], "summary": "Get Security Check Results", "operationId": "GetSecurityCheckResults", + "deprecated": true, "parameters": [ { "name": "body", @@ -20952,6 +20953,7 @@ ], "summary": "Toggle Check Alert", "operationId": "ToggleCheckAlert", + "deprecated": true, "parameters": [ { "name": "body", diff --git a/managed/cmd/pmm-managed-starlark/main.go b/managed/cmd/pmm-managed-starlark/main.go index bf55e01577..8247879f6d 100644 --- a/managed/cmd/pmm-managed-starlark/main.go +++ b/managed/cmd/pmm-managed-starlark/main.go @@ -129,13 +129,13 @@ func runChecks(l *logrus.Entry, data *checks.StarlarkScriptData) ([]check.Result if !ok { return nil, errors.Errorf("unexpected query result type: %T", dbQr) } - if dbRes[dbName], err = unmarshallQueryResult(s); err != nil { + if dbRes[dbName], err = unmarshalQueryResult(s); err != nil { return nil, err } } res[i] = dbRes case string: // used for all other databases - if res[i], err = unmarshallQueryResult(qr); err != nil { + if res[i], err = unmarshalQueryResult(qr); err != nil { return nil, err } default: @@ -158,7 +158,7 @@ func runChecks(l *logrus.Entry, data *checks.StarlarkScriptData) ([]check.Result return results, nil } -func unmarshallQueryResult(qr string) ([]map[string]any, error) { +func unmarshalQueryResult(qr string) ([]map[string]any, error) { b, err := base64.StdEncoding.DecodeString(qr) if err != nil { return nil, errors.Wrap(err, "failed to decode base64 encoded query result") diff --git a/managed/cmd/pmm-managed/main.go b/managed/cmd/pmm-managed/main.go index bc15c61f60..a27c774228 100644 --- a/managed/cmd/pmm-managed/main.go +++ b/managed/cmd/pmm-managed/main.go @@ -912,8 +912,7 @@ func main() { //nolint:cyclop,maintidx l.Fatalf("Could not create Clickhouse client: %s", err) } - checksService := checks.New(db, platformClient, actionsService, alertManager, v1.NewAPI(vmClient), clickhouseClient) - + checksService := checks.New(db, platformClient, actionsService, v1.NewAPI(vmClient), clickhouseClient) prom.MustRegister(checksService) // Integrated alerts services diff --git a/managed/services/checks/checks.go b/managed/services/checks/checks.go index 1d14bedb8b..f0c4c34360 100644 --- a/managed/services/checks/checks.go +++ b/managed/services/checks/checks.go @@ -33,7 +33,6 @@ import ( "time" "github.com/percona-platform/saas/pkg/check" - "github.com/percona-platform/saas/pkg/common" "github.com/pkg/errors" v1 "github.com/prometheus/client_golang/api/prometheus/v1" prom "github.com/prometheus/client_golang/prometheus" @@ -58,7 +57,6 @@ const ( // Environment variables that affect checks service; only for testing. envCheckFile = "PERCONA_TEST_CHECKS_FILE" - envResendInterval = "PERCONA_TEST_CHECKS_RESEND_INTERVAL" envDisableStartDelay = "PERCONA_TEST_CHECKS_DISABLE_START_DELAY" checkExecutionTimeout = 5 * time.Minute // limits execution time for every single check @@ -67,14 +65,9 @@ const ( scriptExecutionTimeout = 5 * time.Second // time limit for running pmm-managed-starlark resultCheckInterval = time.Second - // Sync with API tests. - resolveTimeoutFactor = 3 - defaultResendInterval = 2 * time.Second - prometheusNamespace = "pmm_managed" prometheusSubsystem = "advisor" - alertsPrefix = "/stt/" maxSupportedVersion = 2 ) @@ -91,17 +84,15 @@ var ( // Service is responsible for interactions with Percona Check service. type Service struct { - platformClient *platform.Client - agentsRegistry agentsRegistry - alertmanagerService alertmanagerService - db *reform.DB - alertsRegistry *registry - vmClient v1.API - clickhouseDB *sql.DB + platformClient *platform.Client + agentsRegistry agentsRegistry + db *reform.DB + alertsRegistry *registry + vmClient v1.API + clickhouseDB *sql.DB l *logrus.Entry startDelay time.Duration - resendInterval time.Duration platformPublicKeys []string localChecksFile string // For testing @@ -131,18 +122,11 @@ func New( db *reform.DB, platformClient *platform.Client, agentsRegistry agentsRegistry, - alertmanagerService alertmanagerService, vmClient v1.API, clickhouseDB *sql.DB, ) *Service { l := logrus.WithField("component", "checks") - resendInterval := defaultResendInterval - if d, err := time.ParseDuration(os.Getenv(envResendInterval)); err == nil && d > 0 { - l.Warnf("Interval changed to %s.", d) - resendInterval = d - } - var platformPublicKeys []string if k := envvars.GetPlatformPublicKeys(); k != nil { l.Warnf("Percona Platform public keys changed to %q.", k) @@ -150,17 +134,15 @@ func New( } s := &Service{ - db: db, - agentsRegistry: agentsRegistry, - alertmanagerService: alertmanagerService, - alertsRegistry: newRegistry(resolveTimeoutFactor * resendInterval), - vmClient: vmClient, - clickhouseDB: clickhouseDB, + db: db, + agentsRegistry: agentsRegistry, + alertsRegistry: newRegistry(), + vmClient: vmClient, + clickhouseDB: clickhouseDB, l: l, platformClient: platformClient, startDelay: defaultStartDelay, - resendInterval: resendInterval, platformPublicKeys: platformPublicKeys, localChecksFile: os.Getenv(envCheckFile), @@ -226,12 +208,6 @@ func (s *Service) Run(ctx context.Context) { var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() - s.resendAlerts(ctx) - }() - wg.Add(1) go func() { defer wg.Done() @@ -241,23 +217,6 @@ func (s *Service) Run(ctx context.Context) { wg.Wait() } -// resendAlerts resends collected alerts until ctx is canceled. -func (s *Service) resendAlerts(ctx context.Context) { - t := time.NewTicker(s.resendInterval) - defer t.Stop() - - for { - s.alertmanagerService.SendAlerts(ctx, s.alertsRegistry.collect()) - - select { - case <-ctx.Done(): - return - case <-t.C: - // nothing, continue for loop - } - } -} - // runChecksLoop starts checks execution loop. func (s *Service) runChecksLoop(ctx context.Context) { // First checks run, start all checks from all groups. @@ -298,11 +257,11 @@ func (s *Service) GetSecurityCheckResults() ([]services.CheckResult, error) { return nil, services.ErrAdvisorsDisabled } - return s.alertsRegistry.getCheckResults(), nil + return s.alertsRegistry.getCheckResults(""), nil } // GetChecksResults returns the failed checks for a given service from AlertManager. -func (s *Service) GetChecksResults(ctx context.Context, serviceID string) ([]services.CheckResult, error) { +func (s *Service) GetChecksResults(_ context.Context, serviceID string) ([]services.CheckResult, error) { settings, err := models.GetSettings(s.db) if err != nil { return nil, err @@ -312,59 +271,7 @@ func (s *Service) GetChecksResults(ctx context.Context, serviceID string) ([]ser return nil, services.ErrAdvisorsDisabled } - filters := &services.FilterParams{ - IsCheck: true, - ServiceID: serviceID, - } - res, err := s.alertmanagerService.GetAlerts(ctx, filters) - if err != nil { - return nil, err - } - - checkResults := make([]services.CheckResult, 0, len(res)) - for _, alert := range res { - checkResults = append(checkResults, services.CheckResult{ - CheckName: alert.Labels[model.AlertNameLabel], - Silenced: len(alert.Status.SilencedBy) != 0, - AlertID: alert.Labels["alert_id"], - Interval: check.Interval(alert.Labels["interval_group"]), - Target: services.Target{ - AgentID: alert.Labels["agent_id"], - ServiceID: alert.Labels["service_id"], - ServiceName: alert.Labels["service_name"], - NodeName: alert.Labels["node_name"], - Labels: alert.Labels, - }, - Result: check.Result{ - Summary: alert.Annotations["summary"], - Description: alert.Annotations["description"], - ReadMoreURL: alert.Annotations["read_more_url"], - Severity: common.ParseSeverity(alert.Labels["severity"]), - Labels: alert.Labels, - }, - }) - } - return checkResults, nil -} - -// ToggleCheckAlert toggles the silence state of the check with the provided alertID. -func (s *Service) ToggleCheckAlert(ctx context.Context, alertID string, silence bool) error { - filters := &services.FilterParams{ - IsCheck: true, - AlertID: alertID, - } - res, err := s.alertmanagerService.GetAlerts(ctx, filters) - if err != nil { - return errors.Wrapf(err, "failed to get alerts with id: %s", alertID) - } - - if silence { - err = s.alertmanagerService.SilenceAlerts(ctx, res) - } else { - err = s.alertmanagerService.UnsilenceAlerts(ctx, res) - } - - return err + return s.alertsRegistry.getCheckResults(serviceID), nil } // runChecksGroup downloads and executes Advisors checks that should run in the interval specified by intervalGroup. @@ -411,11 +318,24 @@ func (s *Service) run(ctx context.Context, intervalGroup check.Interval, checkNa return errors.WithStack(err) } - if err := s.executeChecks(ctx, intervalGroup, checkNames); err != nil { + res, err := s.executeChecks(ctx, intervalGroup, checkNames) + if err != nil { return errors.WithStack(err) } - s.alertmanagerService.SendAlerts(ctx, s.alertsRegistry.collect()) + switch { + case len(checkNames) != 0: + // If we run some specific checks, delete previous results for them. + s.alertsRegistry.deleteByName(checkNames) + case intervalGroup != "": + // If we run whole interval group, delete previous results for that group. + s.alertsRegistry.deleteByInterval(intervalGroup) + default: + // If we run all checks, delete all previous results. + s.alertsRegistry.cleanup() + } + + s.alertsRegistry.set(res) return nil } @@ -706,46 +626,32 @@ func (s *Service) filterChecks(checks map[string]check.Check, group check.Interv // executeChecks runs checks for all reachable services. If intervalGroup specified only checks from that group will be // executed. If checkNames specified then only matched checks will be executed. -func (s *Service) executeChecks(ctx context.Context, intervalGroup check.Interval, checkNames []string) error { +func (s *Service) executeChecks(ctx context.Context, intervalGroup check.Interval, checkNames []string) ([]services.CheckResult, error) { disabledChecks, err := s.GetDisabledChecks() if err != nil { - return errors.WithStack(err) + return nil, errors.WithStack(err) } - var checkResults []services.CheckResult + var res []services.CheckResult checks, err := s.GetChecks() if err != nil { - return errors.WithStack(err) + return nil, errors.WithStack(err) } mySQLChecks, postgreSQLChecks, mongoDBChecks := groupChecksByDB(s.l, checks) mySQLChecks = s.filterChecks(mySQLChecks, intervalGroup, disabledChecks, checkNames) mySQLCheckResults := s.executeChecksForTargetType(ctx, models.MySQLServiceType, mySQLChecks) - checkResults = append(checkResults, mySQLCheckResults...) + res = append(res, mySQLCheckResults...) postgreSQLChecks = s.filterChecks(postgreSQLChecks, intervalGroup, disabledChecks, checkNames) postgreSQLCheckResults := s.executeChecksForTargetType(ctx, models.PostgreSQLServiceType, postgreSQLChecks) - checkResults = append(checkResults, postgreSQLCheckResults...) + res = append(res, postgreSQLCheckResults...) mongoDBChecks = s.filterChecks(mongoDBChecks, intervalGroup, disabledChecks, checkNames) mongoDBCheckResults := s.executeChecksForTargetType(ctx, models.MongoDBServiceType, mongoDBChecks) - checkResults = append(checkResults, mongoDBCheckResults...) - - switch { - case len(checkNames) != 0: - // If we run some specific checks, delete previous results for them. - s.alertsRegistry.deleteByName(checkNames) - case intervalGroup != "": - // If we run whole interval group, delete previous results for that group. - s.alertsRegistry.deleteByInterval(intervalGroup) - default: - // If we run all checks, delete all previous results. - s.alertsRegistry.cleanup() - } - - s.alertsRegistry.set(checkResults) + res = append(res, mongoDBCheckResults...) - return nil + return res, nil } func (s *Service) executeChecksForTargetType(ctx context.Context, serviceType models.ServiceType, checks map[string]check.Check) []services.CheckResult { @@ -767,8 +673,10 @@ func (s *Service) executeChecksForTargetType(ctx context.Context, serviceType mo s.mChecksExecuted.WithLabelValues(string(target.ServiceType), c.Advisor, c.Name, "error").Inc() continue } - s.mChecksExecuted.WithLabelValues(string(target.ServiceType), c.Advisor, c.Name, "ok").Inc() + res = append(res, results...) + + s.mChecksExecuted.WithLabelValues(string(target.ServiceType), c.Advisor, c.Name, "ok").Inc() } } diff --git a/managed/services/checks/checks_test.go b/managed/services/checks/checks_test.go index 1eba59211c..2d89d9ddbe 100644 --- a/managed/services/checks/checks_test.go +++ b/managed/services/checks/checks_test.go @@ -28,15 +28,12 @@ import ( "github.com/percona-platform/saas/pkg/common" metrics "github.com/prometheus/client_golang/api" v1 "github.com/prometheus/client_golang/api/prometheus/v1" - "github.com/prometheus/common/model" "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "gopkg.in/reform.v1" "gopkg.in/reform.v1/dialects/postgresql" - "github.com/percona/pmm/api/alertmanager/ammodels" "github.com/percona/pmm/managed/models" "github.com/percona/pmm/managed/services" "github.com/percona/pmm/managed/utils/platform" @@ -72,7 +69,7 @@ func TestDownloadAdvisors(t *testing.T) { platformClient, err := platform.NewClient(db, devPlatformAddress) require.NoError(t, err) - s := New(db, platformClient, nil, nil, vmClient, clickhouseDB) + s := New(db, platformClient, nil, vmClient, clickhouseDB) s.platformPublicKeys = []string{devPlatformPublicKey} require.NoError(t, err) @@ -121,7 +118,7 @@ func TestDownloadAdvisors(t *testing.T) { } func TestLoadLocalChecks(t *testing.T) { - s := New(nil, nil, nil, nil, vmClient, clickhouseDB) + s := New(nil, nil, nil, vmClient, clickhouseDB) checks, err := s.loadLocalChecks(testChecksFile) require.NoError(t, err) @@ -167,7 +164,7 @@ func TestCollectAdvisors(t *testing.T) { require.NoError(t, err) t.Run("collect local checks", func(t *testing.T) { - s := New(db, platformClient, nil, nil, vmClient, clickhouseDB) + s := New(db, platformClient, nil, vmClient, clickhouseDB) s.localChecksFile = testChecksFile s.CollectAdvisors(context.Background()) @@ -198,7 +195,7 @@ func TestCollectAdvisors(t *testing.T) { }) t.Run("download checks", func(t *testing.T) { - s := New(db, platformClient, nil, nil, vmClient, clickhouseDB) + s := New(db, platformClient, nil, vmClient, clickhouseDB) s.platformPublicKeys = []string{devPlatformPublicKey} s.CollectAdvisors(context.Background()) @@ -231,7 +228,7 @@ func TestDisableChecks(t *testing.T) { db := reform.NewDB(sqlDB, postgresql.Dialect, nil) - s := New(db, nil, nil, nil, vmClient, clickhouseDB) + s := New(db, nil, nil, vmClient, clickhouseDB) s.localChecksFile = testChecksFile s.CollectAdvisors(context.Background()) @@ -260,7 +257,7 @@ func TestDisableChecks(t *testing.T) { db := reform.NewDB(sqlDB, postgresql.Dialect, nil) - s := New(db, nil, nil, nil, vmClient, clickhouseDB) + s := New(db, nil, nil, vmClient, clickhouseDB) s.localChecksFile = testChecksFile s.CollectAdvisors(context.Background()) @@ -292,7 +289,7 @@ func TestDisableChecks(t *testing.T) { db := reform.NewDB(sqlDB, postgresql.Dialect, nil) - s := New(db, nil, nil, nil, vmClient, clickhouseDB) + s := New(db, nil, nil, vmClient, clickhouseDB) s.localChecksFile = testChecksFile s.CollectAdvisors(context.Background()) @@ -315,7 +312,7 @@ func TestEnableChecks(t *testing.T) { db := reform.NewDB(sqlDB, postgresql.Dialect, nil) - s := New(db, nil, nil, nil, vmClient, clickhouseDB) + s := New(db, nil, nil, vmClient, clickhouseDB) s.localChecksFile = testChecksFile s.CollectAdvisors(context.Background()) @@ -341,8 +338,6 @@ func TestEnableChecks(t *testing.T) { func TestChangeInterval(t *testing.T) { t.Run("normal", func(t *testing.T) { - var ams mockAlertmanagerService - ams.On("SendAlerts", mock.Anything, mock.Anything).Return() sqlDB := testdb.Open(t, models.SkipFixtures, nil) t.Cleanup(func() { require.NoError(t, sqlDB.Close()) @@ -350,7 +345,7 @@ func TestChangeInterval(t *testing.T) { db := reform.NewDB(sqlDB, postgresql.Dialect, nil) - s := New(db, nil, nil, &ams, vmClient, clickhouseDB) + s := New(db, nil, nil, vmClient, clickhouseDB) s.localChecksFile = testChecksFile s.CollectAdvisors(context.Background()) @@ -395,7 +390,7 @@ func TestGetSecurityCheckResults(t *testing.T) { db := reform.NewDB(sqlDB, postgresql.Dialect, nil) t.Run("STT enabled", func(t *testing.T) { - s := New(db, nil, nil, nil, vmClient, clickhouseDB) + s := New(db, nil, nil, vmClient, clickhouseDB) results, err := s.GetSecurityCheckResults() assert.Empty(t, results) @@ -403,7 +398,7 @@ func TestGetSecurityCheckResults(t *testing.T) { }) t.Run("STT disabled", func(t *testing.T) { - s := New(db, nil, nil, nil, vmClient, clickhouseDB) + s := New(db, nil, nil, vmClient, clickhouseDB) settings, err := models.GetSettings(db) require.NoError(t, err) @@ -428,7 +423,7 @@ func TestStartChecks(t *testing.T) { setupClients(t) t.Run("unknown interval", func(t *testing.T) { - s := New(db, nil, nil, nil, vmClient, clickhouseDB) + s := New(db, nil, nil, vmClient, clickhouseDB) s.localChecksFile = testChecksFile err := s.runChecksGroup(context.Background(), check.Interval("unknown")) @@ -436,10 +431,7 @@ func TestStartChecks(t *testing.T) { }) t.Run("stt enabled", func(t *testing.T) { - var ams mockAlertmanagerService - ams.On("SendAlerts", mock.Anything, mock.Anything).Return() - - s := New(db, nil, nil, &ams, vmClient, clickhouseDB) + s := New(db, nil, nil, vmClient, clickhouseDB) s.localChecksFile = testChecksFile s.CollectAdvisors(context.Background()) @@ -451,7 +443,7 @@ func TestStartChecks(t *testing.T) { }) t.Run("stt disabled", func(t *testing.T) { - s := New(db, nil, nil, nil, vmClient, clickhouseDB) + s := New(db, nil, nil, vmClient, clickhouseDB) settings, err := models.GetSettings(db) require.NoError(t, err) @@ -541,7 +533,7 @@ func TestFilterChecks(t *testing.T) { partiallyValidAdvisor.Checks = partiallyValidAdvisor.Checks[0:1] // remove invalid check expected := append(valid, partiallyValidAdvisor) //nolint:gocritic - s := New(nil, nil, nil, nil, vmClient, clickhouseDB) + s := New(nil, nil, nil, vmClient, clickhouseDB) actual := s.filterSupportedChecks(checks) assert.ElementsMatch(t, expected, actual) } @@ -566,7 +558,7 @@ func TestMinPMMAgents(t *testing.T) { {name: "PostgreSQL Family", minVersion: pmmAgent2_6_0, check: check.Check{Version: 2, Queries: []check.Query{{Type: check.PostgreSQLShow}, {Type: check.PostgreSQLSelect}}}}, } - s := New(nil, nil, nil, nil, vmClient, clickhouseDB) + s := New(nil, nil, nil, vmClient, clickhouseDB) for _, test := range tests { test := test @@ -627,7 +619,7 @@ func TestFindTargets(t *testing.T) { db := reform.NewDB(sqlDB, postgresql.Dialect, reform.NewPrintfLogger(t.Logf)) - s := New(db, nil, nil, nil, vmClient, clickhouseDB) + s := New(db, nil, nil, vmClient, clickhouseDB) t.Run("unknown service", func(t *testing.T) { t.Parallel() @@ -680,7 +672,7 @@ func TestFindTargets(t *testing.T) { func TestFilterChecksByInterval(t *testing.T) { t.Parallel() - s := New(nil, nil, nil, nil, vmClient, clickhouseDB) + s := New(nil, nil, nil, vmClient, clickhouseDB) rareCheck := check.Check{Name: "rareCheck", Interval: check.Rare} standardCheck := check.Check{Name: "standardCheck", Interval: check.Standard} @@ -713,11 +705,7 @@ func TestGetFailedChecks(t *testing.T) { db := reform.NewDB(sqlDB, postgresql.Dialect, nil) t.Run("no failed check for service", func(t *testing.T) { - var ams mockAlertmanagerService - ctx := context.Background() - ams.On("GetAlerts", ctx, mock.Anything).Return([]*ammodels.GettableAlert{}, nil) - - s := New(db, nil, nil, &ams, vmClient, clickhouseDB) + s := New(db, nil, nil, vmClient, clickhouseDB) results, err := s.GetChecksResults(context.Background(), "test_svc") assert.Empty(t, results) @@ -725,65 +713,112 @@ func TestGetFailedChecks(t *testing.T) { }) t.Run("non empty failed checks", func(t *testing.T) { - alertLabels := map[string]string{ - model.AlertNameLabel: "test_check", - "alert_id": "test_alert", - "service_name": "test_svc", - "service_id": "/service_id/test_svc1", - "interval_group": "frequent", - "severity": common.Severity(4).String(), - } - - testAlert := ammodels.GettableAlert{ - Annotations: map[string]string{ - "summary": "Check summary", - "description": "Check description", - "read_more_url": "https://www.example.com", + checkResults := []services.CheckResult{ + { + CheckName: "test_check", + Interval: check.Frequent, + Target: services.Target{ + ServiceName: "test_svc1", + ServiceID: "/service_id/test_svc1", + Labels: map[string]string{ + "targetLabel": "targetLabelValue", + }, + }, + Result: check.Result{ + Summary: "Check summary", + Description: "Check description", + ReadMoreURL: "https://www.example.com", + Severity: common.Error, + Labels: map[string]string{ + "resultLabel": "reslutLabelValue", + }, + }, }, - Alert: ammodels.Alert{ - Labels: alertLabels, + { + CheckName: "test_check2", + Interval: check.Frequent, + Target: services.Target{ + ServiceName: "test_svc2", + ServiceID: "/service_id/test_svc2", + Labels: map[string]string{ + "targetLabel": "targetLabelValue", + }, + }, + Result: check.Result{ + Summary: "Check summary", + Description: "Check description", + ReadMoreURL: "https://www.example.com", + Severity: common.Error, + Labels: map[string]string{ + "resultLabel": "reslutLabelValue", + }, + }, }, - Status: &ammodels.AlertStatus{}, } - results := []services.CheckResult{ + s := New(db, nil, nil, vmClient, clickhouseDB) + s.alertsRegistry.set(checkResults) + + response, err := s.GetChecksResults(context.Background(), "") + require.NoError(t, err) + assert.ElementsMatch(t, checkResults, response) + }) + + t.Run("non empty failed checks for specific service", func(t *testing.T) { + checkResults := []services.CheckResult{ { CheckName: "test_check", - AlertID: "test_alert", - Silenced: false, Interval: check.Frequent, Target: services.Target{ - ServiceName: "test_svc", + ServiceName: "test_svc1", ServiceID: "/service_id/test_svc1", - Labels: alertLabels, + Labels: map[string]string{ + "targetLabel": "targetLabelValue", + }, }, Result: check.Result{ Summary: "Check summary", Description: "Check description", ReadMoreURL: "https://www.example.com", Severity: common.Error, - Labels: alertLabels, + Labels: map[string]string{ + "resultLabel": "reslutLabelValue", + }, + }, + }, + { + CheckName: "test_check2", + Interval: check.Frequent, + Target: services.Target{ + ServiceName: "test_svc2", + ServiceID: "/service_id/test_svc2", + Labels: map[string]string{ + "targetLabel": "targetLabelValue", + }, + }, + Result: check.Result{ + Summary: "Check summary", + Description: "Check description", + ReadMoreURL: "https://www.example.com", + Severity: common.Error, + Labels: map[string]string{ + "resultLabel": "reslutLabelValue", + }, }, }, } - ams := mockAlertmanagerService{} - ctx := context.Background() - ams.On("GetAlerts", ctx, mock.Anything).Return([]*ammodels.GettableAlert{&testAlert}, nil) - - s := New(db, nil, nil, &ams, vmClient, clickhouseDB) + s := New(db, nil, nil, vmClient, clickhouseDB) + s.alertsRegistry.set(checkResults) - response, err := s.GetChecksResults(ctx, "test_svc") + response, err := s.GetChecksResults(context.Background(), "/service_id/test_svc1") require.NoError(t, err) - assert.Equal(t, results, response) + require.Len(t, response, 1) + assert.Equal(t, checkResults[0], response[0]) }) t.Run("STT disabled", func(t *testing.T) { - ams := mockAlertmanagerService{} - ctx := context.Background() - ams.On("GetAlerts", ctx, mock.Anything).Return(nil, services.ErrAdvisorsDisabled) - - s := New(db, nil, nil, &ams, vmClient, clickhouseDB) + s := New(db, nil, nil, vmClient, clickhouseDB) settings, err := models.GetSettings(db) require.NoError(t, err) @@ -792,66 +827,12 @@ func TestGetFailedChecks(t *testing.T) { err = models.SaveSettings(db, settings) require.NoError(t, err) - results, err := s.GetChecksResults(ctx, "test_svc") + results, err := s.GetChecksResults(context.Background(), "test_svc") assert.Nil(t, results) assert.ErrorIs(t, err, services.ErrAdvisorsDisabled) }) } -func TestToggleCheckAlert(t *testing.T) { - t.Parallel() - - t.Run("silence alert", func(t *testing.T) { - t.Parallel() - - testAlert := &ammodels.GettableAlert{ - Alert: ammodels.Alert{ - Labels: map[string]string{ - "alert_id": "test_alert_1", - }, - }, - Status: &ammodels.AlertStatus{}, - } - - var ams mockAlertmanagerService - ctx := context.Background() - ams.On("GetAlerts", ctx, mock.Anything).Return([]*ammodels.GettableAlert{testAlert}, nil) - ams.On("SilenceAlerts", ctx, []*ammodels.GettableAlert{testAlert}).Return(nil) - - s := New(nil, nil, nil, &ams, vmClient, clickhouseDB) - - active := len(testAlert.Status.SilencedBy) == 0 - err := s.ToggleCheckAlert(ctx, "test_alert_1", active) - require.NoError(t, err) - ams.AssertCalled(t, "SilenceAlerts", ctx, []*ammodels.GettableAlert{testAlert}) - }) - - t.Run("unsilence alert", func(t *testing.T) { - t.Parallel() - - testAlert := &ammodels.GettableAlert{ - Alert: ammodels.Alert{ - Labels: map[string]string{ - "alert_id": "test_alert_2", - }, - }, - Status: &ammodels.AlertStatus{SilencedBy: []string{"test_silence"}}, - } - - var ams mockAlertmanagerService - ctx := context.Background() - ams.On("GetAlerts", ctx, mock.Anything).Return([]*ammodels.GettableAlert{testAlert}, nil) - ams.On("UnsilenceAlerts", ctx, []*ammodels.GettableAlert{testAlert}).Return(nil) - - s := New(nil, nil, nil, &ams, vmClient, clickhouseDB) - - active := len(testAlert.Status.SilencedBy) == 0 - err := s.ToggleCheckAlert(ctx, "test_alert_1", active) - require.NoError(t, err) - ams.AssertCalled(t, "UnsilenceAlerts", ctx, []*ammodels.GettableAlert{testAlert}) - }) -} - func TestFillQueryPlaceholders(t *testing.T) { t.Parallel() diff --git a/managed/services/checks/deps.go b/managed/services/checks/deps.go index d4b3feeccb..267d69b5f5 100644 --- a/managed/services/checks/deps.go +++ b/managed/services/checks/deps.go @@ -18,13 +18,10 @@ package checks import ( "context" - "github.com/percona/pmm/api/alertmanager/ammodels" "github.com/percona/pmm/managed/models" - "github.com/percona/pmm/managed/services" ) //go:generate ../../../bin/mockery --name=agentsRegistry --case=snake --inpackage --testonly -//go:generate ../../../bin/mockery --name=alertmanagerService --case=snake --inpackage --testonly // agentsRegistry is a subset of methods of agents.Registry used by this package. // We use it instead of real type for testing and to avoid dependency cycle. @@ -39,12 +36,3 @@ type agentsRegistry interface { StartMongoDBQueryReplSetGetStatusAction(ctx context.Context, id, pmmAgentID, dsn string, files map[string]string, tdp *models.DelimiterPair) error StartMongoDBQueryGetDiagnosticDataAction(ctx context.Context, id, pmmAgentID, dsn string, files map[string]string, tdp *models.DelimiterPair) error } - -// alertmanagerService is a subset of methods of alertmanager.Service used by this package. -// We use it instead of real type for testing and to avoid dependency cycle. -type alertmanagerService interface { - SendAlerts(ctx context.Context, alerts ammodels.PostableAlerts) - SilenceAlerts(ctx context.Context, alerts []*ammodels.GettableAlert) error - UnsilenceAlerts(ctx context.Context, alerts []*ammodels.GettableAlert) error - GetAlerts(ctx context.Context, params *services.FilterParams) ([]*ammodels.GettableAlert, error) -} diff --git a/managed/services/checks/mock_alertmanager_service_test.go b/managed/services/checks/mock_alertmanager_service_test.go deleted file mode 100644 index 4877388dc3..0000000000 --- a/managed/services/checks/mock_alertmanager_service_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// Code generated by mockery v2.33.0. DO NOT EDIT. - -package checks - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" - - ammodels "github.com/percona/pmm/api/alertmanager/ammodels" - services "github.com/percona/pmm/managed/services" -) - -// mockAlertmanagerService is an autogenerated mock type for the alertmanagerService type -type mockAlertmanagerService struct { - mock.Mock -} - -// GetAlerts provides a mock function with given fields: ctx, params -func (_m *mockAlertmanagerService) GetAlerts(ctx context.Context, params *services.FilterParams) ([]*ammodels.GettableAlert, error) { - ret := _m.Called(ctx, params) - - var r0 []*ammodels.GettableAlert - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *services.FilterParams) ([]*ammodels.GettableAlert, error)); ok { - return rf(ctx, params) - } - if rf, ok := ret.Get(0).(func(context.Context, *services.FilterParams) []*ammodels.GettableAlert); ok { - r0 = rf(ctx, params) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*ammodels.GettableAlert) - } - } - - if rf, ok := ret.Get(1).(func(context.Context, *services.FilterParams) error); ok { - r1 = rf(ctx, params) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// SendAlerts provides a mock function with given fields: ctx, alerts -func (_m *mockAlertmanagerService) SendAlerts(ctx context.Context, alerts ammodels.PostableAlerts) { - _m.Called(ctx, alerts) -} - -// SilenceAlerts provides a mock function with given fields: ctx, alerts -func (_m *mockAlertmanagerService) SilenceAlerts(ctx context.Context, alerts []*ammodels.GettableAlert) error { - ret := _m.Called(ctx, alerts) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, []*ammodels.GettableAlert) error); ok { - r0 = rf(ctx, alerts) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// UnsilenceAlerts provides a mock function with given fields: ctx, alerts -func (_m *mockAlertmanagerService) UnsilenceAlerts(ctx context.Context, alerts []*ammodels.GettableAlert) error { - ret := _m.Called(ctx, alerts) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, []*ammodels.GettableAlert) error); ok { - r0 = rf(ctx, alerts) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// newMockAlertmanagerService creates a new instance of mockAlertmanagerService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func newMockAlertmanagerService(t interface { - mock.TestingT - Cleanup(func()) -}, -) *mockAlertmanagerService { - mock := &mockAlertmanagerService{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/managed/services/checks/registry.go b/managed/services/checks/registry.go index b357de660a..2be7d5c706 100644 --- a/managed/services/checks/registry.go +++ b/managed/services/checks/registry.go @@ -16,18 +16,11 @@ package checks import ( - "crypto/sha1" //nolint:gosec - "encoding/hex" - "fmt" "sync" - "time" - "github.com/go-openapi/strfmt" "github.com/percona-platform/saas/pkg/check" prom "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/common/model" - "github.com/percona/pmm/api/alertmanager/ammodels" "github.com/percona/pmm/managed/services" ) @@ -36,20 +29,13 @@ type registry struct { rw sync.RWMutex // Results stored grouped by interval and by check name. It allows us to remove results for specific group. checkResults map[check.Interval]map[string][]services.CheckResult - - alertTTL time.Duration - nowF func() time.Time // for tests - - mInsights *prom.GaugeVec + mInsights *prom.GaugeVec } // newRegistry creates a new registry. -func newRegistry(alertTTL time.Duration) *registry { +func newRegistry() *registry { return ®istry{ checkResults: make(map[check.Interval]map[string][]services.CheckResult), - alertTTL: alertTTL, - nowF: time.Now, - mInsights: prom.NewGaugeVec(prom.GaugeOpts{ Namespace: prometheusNamespace, Subsystem: prometheusSubsystem, @@ -105,70 +91,25 @@ func (r *registry) cleanup() { r.checkResults = make(map[check.Interval]map[string][]services.CheckResult) } -// collect returns a slice of alerts created from the stored check results. -func (r *registry) collect() ammodels.PostableAlerts { +// getCheckResults returns checks results for the given service. If serviceID is empty it returns results for all services. +func (r *registry) getCheckResults(serviceID string) []services.CheckResult { r.rw.RLock() defer r.rw.RUnlock() - var alerts ammodels.PostableAlerts + var results []services.CheckResult for _, intervalGroup := range r.checkResults { for _, checkNameGroup := range intervalGroup { for _, checkResult := range checkNameGroup { - checkResult := checkResult - alerts = append(alerts, r.createAlert(&checkResult)) + if serviceID == "" || checkResult.Target.ServiceID == serviceID { + results = append(results, checkResult) + } } } } - return alerts -} - -func (r *registry) getCheckResults() []services.CheckResult { - r.rw.RLock() - defer r.rw.RUnlock() - - var results []services.CheckResult - for _, intervalGroup := range r.checkResults { - for _, checkNameGroup := range intervalGroup { - results = append(results, checkNameGroup...) - } - } return results } -func (r *registry) createAlert(checkResult *services.CheckResult) *ammodels.PostableAlert { - name, target, result, alertTTL := checkResult.CheckName, &checkResult.Target, &checkResult.Result, r.alertTTL - labels := make(map[string]string, len(target.Labels)+len(result.Labels)+4) - annotations := make(map[string]string, 2) - for k, v := range result.Labels { - labels[k] = v - } - for k, v := range target.Labels { - labels[k] = v - } - - labels[model.AlertNameLabel] = name - checkResult.AlertID = makeID(target, result) - labels["severity"] = result.Severity.String() - labels["stt_check"] = "1" - labels["alert_id"] = checkResult.AlertID - labels["interval_group"] = string(checkResult.Interval) - - annotations["summary"] = result.Summary - annotations["description"] = result.Description - annotations["read_more_url"] = result.ReadMoreURL - - endsAt := r.nowF().Add(alertTTL).UTC().Round(0) // strip a monotonic clock reading - return &ammodels.PostableAlert{ - Alert: ammodels.Alert{ - // GeneratorURL: "TODO", - Labels: labels, - }, - EndsAt: strfmt.DateTime(endsAt), - Annotations: annotations, - } -} - // Describe implements prom.Collector. func (r *registry) Describe(ch chan<- *prom.Desc) { r.mInsights.Describe(ch) @@ -177,21 +118,9 @@ func (r *registry) Describe(ch chan<- *prom.Desc) { // Collect implements prom.Collector. func (r *registry) Collect(ch chan<- prom.Metric) { r.mInsights.Reset() - res := r.getCheckResults() + res := r.getCheckResults("") for _, re := range res { r.mInsights.WithLabelValues(string(re.Target.ServiceType), re.AdvisorName, re.CheckName).Inc() } r.mInsights.Collect(ch) } - -// makeID creates an ID for STT check alert. -func makeID(target *services.Target, result *check.Result) string { - s := sha1.New() //nolint:gosec - fmt.Fprintf(s, "%s\n", target.AgentID) - fmt.Fprintf(s, "%s\n", target.ServiceID) - fmt.Fprintf(s, "%s\n", result.Summary) - fmt.Fprintf(s, "%s\n", result.Description) - fmt.Fprintf(s, "%s\n", result.ReadMoreURL) - fmt.Fprintf(s, "%v\n", result.Severity) - return alertsPrefix + hex.EncodeToString(s.Sum(nil)) -} diff --git a/managed/services/checks/registry_test.go b/managed/services/checks/registry_test.go index 0b4ca97e9b..ae5eb55f1d 100644 --- a/managed/services/checks/registry_test.go +++ b/managed/services/checks/registry_test.go @@ -17,25 +17,18 @@ package checks import ( "testing" - "time" - "github.com/go-openapi/strfmt" "github.com/percona-platform/saas/pkg/check" "github.com/percona-platform/saas/pkg/common" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/percona/pmm/api/alertmanager/ammodels" "github.com/percona/pmm/managed/services" ) func TestRegistry(t *testing.T) { t.Run("create and collect Alerts", func(t *testing.T) { - alertTTL := resolveTimeoutFactor * defaultResendInterval - r := newRegistry(alertTTL) - - nowValue := time.Now().UTC().Round(0) // strip a monotonic clock reading - r.nowF = func() time.Time { return nowValue } + r := newRegistry() checkResults := []services.CheckResult{ { CheckName: "name", @@ -80,57 +73,15 @@ func TestRegistry(t *testing.T) { r.set(checkResults) - expectedAlerts := []*ammodels.PostableAlert{ - { - Annotations: map[string]string{ - "summary": "check summary", - "description": "check description", - "read_more_url": "https://www.example.com", - }, - EndsAt: strfmt.DateTime(nowValue.Add(alertTTL)), - Alert: ammodels.Alert{ - Labels: map[string]string{ - "alert_id": "/stt/e7b471407fe9734eac5b6adb178ee0ef08ef45f2", - "alertname": "name", - "baz": "qux", - "foo": "bar", - "severity": "warning", - "stt_check": "1", - "interval_group": string(check.Standard), - }, - }, - }, - { - Annotations: map[string]string{ - "summary": "check summary 2", - "description": "check description 2", - "read_more_url": "https://www.example2.com", - }, - EndsAt: strfmt.DateTime(nowValue.Add(alertTTL)), - Alert: ammodels.Alert{ - Labels: map[string]string{ - "alert_id": "/stt/8fa5695dc34160333eeeb05f00bf1ddbd98be59c", - "alertname": "name2", - "qux": "baz", - "bar": "foo", - "severity": "notice", - "stt_check": "1", - "interval_group": string(check.Standard), - }, - }, - }, - } + // Empty interval means standard + checkResults[1].Interval = check.Standard - collectedAlerts := r.collect() - assert.ElementsMatch(t, expectedAlerts, collectedAlerts) + collectedAlerts := r.getCheckResults("") + assert.ElementsMatch(t, checkResults, collectedAlerts) }) t.Run("delete check results by interval", func(t *testing.T) { - alertTTL := resolveTimeoutFactor * defaultResendInterval - r := newRegistry(alertTTL) - - nowValue := time.Now().UTC().Round(0) // strip a monotonic clock reading - r.nowF = func() time.Time { return nowValue } + r := newRegistry() checkResults := []services.CheckResult{ { CheckName: "name", @@ -177,40 +128,17 @@ func TestRegistry(t *testing.T) { r.set(checkResults) r.deleteByInterval(check.Standard) - expectedAlert := &ammodels.PostableAlert{ - Annotations: map[string]string{ - "summary": "check summary 2", - "description": "check description 2", - "read_more_url": "https://www.example2.com", - }, - EndsAt: strfmt.DateTime(nowValue.Add(alertTTL)), - Alert: ammodels.Alert{ - Labels: map[string]string{ - "alert_id": "/stt/8fa5695dc34160333eeeb05f00bf1ddbd98be59c", - "alertname": "name2", - "qux": "baz", - "bar": "foo", - "severity": "notice", - "stt_check": "1", - "interval_group": string(check.Frequent), - }, - }, - } - - collectedAlerts := r.collect() + collectedAlerts := r.getCheckResults("") require.Len(t, collectedAlerts, 1) - assert.Equal(t, expectedAlert, collectedAlerts[0]) + assert.Equal(t, checkResults[1], collectedAlerts[0]) }) t.Run("delete check result by name", func(t *testing.T) { - alertTTL := resolveTimeoutFactor * defaultResendInterval - r := newRegistry(alertTTL) - - nowValue := time.Now().UTC().Round(0) // strip a monotonic clock reading - r.nowF = func() time.Time { return nowValue } + r := newRegistry() checkResults := []services.CheckResult{ { CheckName: "name1", + Interval: check.Standard, Target: services.Target{ AgentID: "/agent_id/123", ServiceID: "/service_id/123", @@ -230,6 +158,7 @@ func TestRegistry(t *testing.T) { }, { CheckName: "name2", + Interval: check.Standard, Target: services.Target{ AgentID: "/agent_id/321", ServiceID: "/service_id/321", @@ -252,37 +181,13 @@ func TestRegistry(t *testing.T) { r.set(checkResults) r.deleteByName([]string{"name1"}) - expectedAlert := &ammodels.PostableAlert{ - Annotations: map[string]string{ - "summary": "check summary 2", - "description": "check description 2", - "read_more_url": "https://www.example2.com", - }, - EndsAt: strfmt.DateTime(nowValue.Add(alertTTL)), - Alert: ammodels.Alert{ - Labels: map[string]string{ - "alert_id": "/stt/8fa5695dc34160333eeeb05f00bf1ddbd98be59c", - "alertname": "name2", - "qux": "baz", - "bar": "foo", - "severity": "notice", - "stt_check": "1", - "interval_group": string(check.Standard), - }, - }, - } - - collectedAlerts := r.collect() + collectedAlerts := r.getCheckResults("") require.Len(t, collectedAlerts, 1) - assert.Equal(t, expectedAlert, collectedAlerts[0]) + assert.Equal(t, checkResults[1], collectedAlerts[0]) }) t.Run("empty interval recognized as standard", func(t *testing.T) { - alertTTL := resolveTimeoutFactor * defaultResendInterval - r := newRegistry(alertTTL) - - nowValue := time.Now().UTC().Round(0) // strip a monotonic clock reading - r.nowF = func() time.Time { return nowValue } + r := newRegistry() checkResults := []services.CheckResult{ { CheckName: "name", @@ -328,7 +233,7 @@ func TestRegistry(t *testing.T) { r.set(checkResults) r.deleteByInterval(check.Standard) - collectedAlerts := r.collect() + collectedAlerts := r.getCheckResults("") assert.Empty(t, collectedAlerts) }) } diff --git a/managed/services/management/checks.go b/managed/services/management/checks.go index 705448cd0e..999e63b733 100644 --- a/managed/services/management/checks.go +++ b/managed/services/management/checks.go @@ -122,17 +122,23 @@ func (s *ChecksAPIService) GetFailedChecks(ctx context.Context, req *managementp failedChecks := make([]*managementpb.CheckResult, 0, len(results)) for _, result := range results { + labels := make(map[string]string, len(result.Target.Labels)+len(result.Result.Labels)) + for k, v := range result.Result.Labels { + labels[k] = v + } + for k, v := range result.Target.Labels { + labels[k] = v + } + failedChecks = append(failedChecks, &managementpb.CheckResult{ Summary: result.Result.Summary, CheckName: result.CheckName, Description: result.Result.Description, ReadMoreUrl: result.Result.ReadMoreURL, Severity: managementpb.Severity(result.Result.Severity), - Labels: result.Result.Labels, + Labels: labels, ServiceName: result.Target.ServiceName, ServiceId: result.Target.ServiceID, - AlertId: result.AlertID, - Silenced: result.Silenced, }) } @@ -167,12 +173,7 @@ func (s *ChecksAPIService) GetFailedChecks(ctx context.Context, req *managementp // ToggleCheckAlert toggles the silence state of the check with the provided alertID. func (s *ChecksAPIService) ToggleCheckAlert(ctx context.Context, req *managementpb.ToggleCheckAlertRequest) (*managementpb.ToggleCheckAlertResponse, error) { - err := s.checksService.ToggleCheckAlert(ctx, req.AlertId, req.Silence) - if err != nil { - return nil, errors.Wrapf(err, "failed to toggle silence status of alert with id: %s", req.AlertId) - } - - return &managementpb.ToggleCheckAlertResponse{}, nil + return nil, status.Error(codes.NotFound, "Advisor alerts silencing is not supported anymore.") } // GetSecurityCheckResults returns Security Thread Tool's latest checks results. diff --git a/managed/services/management/deps.go b/managed/services/management/deps.go index 1a873f89a4..b87ae574e3 100644 --- a/managed/services/management/deps.go +++ b/managed/services/management/deps.go @@ -71,7 +71,6 @@ type checksService interface { DisableChecks(checkNames []string) error EnableChecks(checkNames []string) error ChangeInterval(params map[string]check.Interval) error - ToggleCheckAlert(ctx context.Context, alertID string, newStatus bool) error } // grafanaClient is a subset of methods of grafana.Client used by this package. diff --git a/managed/services/management/mock_checks_service_test.go b/managed/services/management/mock_checks_service_test.go index 53131de5ab..d28cd5cb01 100644 --- a/managed/services/management/mock_checks_service_test.go +++ b/managed/services/management/mock_checks_service_test.go @@ -202,20 +202,6 @@ func (_m *mockChecksService) StartChecks(checkNames []string) error { return r0 } -// ToggleCheckAlert provides a mock function with given fields: ctx, alertID, newStatus -func (_m *mockChecksService) ToggleCheckAlert(ctx context.Context, alertID string, newStatus bool) error { - ret := _m.Called(ctx, alertID, newStatus) - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, bool) error); ok { - r0 = rf(ctx, alertID, newStatus) - } else { - r0 = ret.Error(0) - } - - return r0 -} - // newMockChecksService creates a new instance of mockChecksService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func newMockChecksService(t interface { diff --git a/managed/services/types.go b/managed/services/types.go index 2614d4fed2..04720ff2f5 100644 --- a/managed/services/types.go +++ b/managed/services/types.go @@ -66,8 +66,6 @@ func (t *Target) Copy() Target { type CheckResult struct { CheckName string AdvisorName string - Silenced bool - AlertID string Interval check.Interval Target Target Result check.Result