WIP: Request all kind of stats through ES instead of each service #1
@ -207,19 +207,76 @@
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$url = "https://mattermost.gnous.fr/api/v4/analytics/old";
|
$url = "https://mon.gnous.fr:9200/stats-*/_search";
|
||||||
$headers = array(
|
$headers = array(
|
||||||
"Accept: application/json",
|
"Content-Type: application/json",
|
||||||
"Authorization: Bearer ".$_ENV["MM_TOKEN"],
|
"Authorization: Basic ".$_ENV["ES_TOKEN"],
|
||||||
);
|
);
|
||||||
|
$params = '
|
||||||
|
{
|
||||||
|
"sort": { "@timestamp": "desc"},
|
||||||
|
"size": 5,
|
||||||
|
"query": {
|
||||||
|
"bool": {
|
||||||
|
"filter": [
|
||||||
|
{
|
||||||
|
"match_phrase": {
|
||||||
|
"fields.stats": "mattermost"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bool": {
|
||||||
|
"should": [
|
||||||
|
{
|
||||||
|
"match_phrase": {
|
||||||
|
"stats.name": "post_count"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match_phrase": {
|
||||||
|
"stats.name": "channel_open_count"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match_phrase": {
|
||||||
|
"stats.name": "channel_private_count"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match_phrase": {
|
||||||
|
"stats.name": "unique_user_count"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match_phrase": {
|
||||||
|
"stats.name": "team_count"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"minimum_should_match": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"fields": [
|
||||||
|
"stats.*"
|
||||||
|
],
|
||||||
|
"_source" :false
|
||||||
|
}';
|
||||||
|
|
||||||
$ch = curl_init($url);
|
$ch = curl_init($url);
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||||
|
curl_setopt($ch, CURLOPT_CAINFO,'./ressources/elasticsearch-ca.pem');
|
||||||
|
curl_setopt($ch, CURLOPT_CAPATH,'./ressources/elasticsearch-ca.pem');
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
|
||||||
|
curl_setopt($ch, CURLOPT_VERBOSE, true);
|
||||||
|
|
||||||
$data_json = curl_exec($ch);
|
$data_json = curl_exec($ch);
|
||||||
|
echo $data_json;
|
||||||
|
//var_dump(json_decode($data_json));
|
||||||
$status_code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
|
$status_code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
|
||||||
|
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
@ -397,3 +454,4 @@ if ($status_code==200) {
|
|||||||
<?php include 'includes/footer.php'; ?>
|
<?php include 'includes/footer.php'; ?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
21
html/ressources/elasticsearch-ca.pem
Normal file
21
html/ressources/elasticsearch-ca.pem
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDSTCCAjGgAwIBAgIUFtJbVhXjO+79FhUNlF3ArhDMqW8wDQYJKoZIhvcNAQEL
|
||||||
|
BQAwNDEyMDAGA1UEAxMpRWxhc3RpYyBDZXJ0aWZpY2F0ZSBUb29sIEF1dG9nZW5l
|
||||||
|
cmF0ZWQgQ0EwHhcNMjAxMjA5MjIzOTA4WhcNMjMxMjA5MjIzOTA4WjA0MTIwMAYD
|
||||||
|
VQQDEylFbGFzdGljIENlcnRpZmljYXRlIFRvb2wgQXV0b2dlbmVyYXRlZCBDQTCC
|
||||||
|
ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMidINHA7k45Z5PF6dITX44R
|
||||||
|
sbCpbeJXO/qCIlOVUphbxBrGP2Cbf0z5zcjMA/+nh2DIymbujK1KHkBlGmX8RMHy
|
||||||
|
c77YBDZpm7y5uK/M31fQDizArHhdHPMFi8L2h/b9Ppvl3y6NpYD3Ukx6TU8ZNin3
|
||||||
|
bGWWCEwy2+t4tY1J4xBJhbo0emxFqA//exIklk4iYay+yk2p4jPRaLQQtJ2VcnKj
|
||||||
|
nbgVDOpvZvuklWk1jMxGJ5it1EULL3TK1PoAYcyDED1Nur4ACKDjjhumVodLGJCh
|
||||||
|
mOK8MGH6b4p5VIPzrDhxfeOu1w47S+Y5kC/uUut6JAgDyq0HcTV0XQnJOyE6He8C
|
||||||
|
AwEAAaNTMFEwHQYDVR0OBBYEFF6vtkkInPGnyi7iDD0fYYxauPIRMB8GA1UdIwQY
|
||||||
|
MBaAFF6vtkkInPGnyi7iDD0fYYxauPIRMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZI
|
||||||
|
hvcNAQELBQADggEBAEseDZkOKbiD6k7KM+t26F553Y2HOA6xIP4CHNmld/ntHZbj
|
||||||
|
z3BvXgt5u3vOgyCS8u1LbtYXdELNUS7xMPeedNLsU+rrsxM8JU1/dH0tzPgTz1Is
|
||||||
|
ZPE4qAs0aEpNm0wxXd+D2oOBJYXb0C0Xv/GAG4sxBt7mpUMGYEs3PQjIQ4wj/Xe/
|
||||||
|
3D9X5XLodAG6VCFpeiTWQcbhTYPnzLowaPKkhUAsJUYcK0DSND8YjB7n1jxNxcvE
|
||||||
|
So146uzgHmCGG+ogRJmtrCNaixQWA+rCfn6/kUePrm0TF2k8befUIkkWmirg8oBo
|
||||||
|
C1VeCAFIIHd9KGs+D4eYVsd3PbnYInRPJ58HHbA=
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
|
Loading…
Reference in New Issue
Block a user