annotate mod_http_stats_stream/README.markdown @ 4989:b74d592df9e2

mod_http_muc_log: Remove dead code This might be something left over since a different variant where the loop went like `for n = i-1, i-100, -1 do ... end` i.e. it went trough a fixed number of items instead of all the page until the current message. Then it would have needed something to stop going over the end, but since the checks are simple it shouldn't be much of a problem looping over even a very busy day.
author Kim Alvefur <zash@zash.se>
date Tue, 16 Aug 2022 01:27:59 +0200
parents bac3dae031ee
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2480
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 ---
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2 depends:
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 - 'mod\_http'
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4 provides:
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 - http
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6 ---
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8 # Introduction
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
9
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
10 This module provides a streaming interface to [Prosodys internal statistics][doc:statistics] via
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
11 [Server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events).
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
12
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13 ## Example
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15 ```js
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
16 var evtSource = new EventSource("/stats_stream");
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
17
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
18 /*
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
19 * An event with all current statistics in the form of a JSON object.
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
20 * Normally sent only once, when first connected to the stream.
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
21 */
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
22 evtSource.addEventListener("stats-full", function(e) {
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
23 var initial_stats = JSON.parse(e.data);
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
24 console.log(initial_stats);
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
25 }, false);
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
26
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
27 /*
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
28 * An event containing only statistics that have changed since the last
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
29 * 'stats-full' or 'stats-updated' event.
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
30 */
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
31 evtSource.addEventListener("stats-updated", function(e) {
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
32 var updated_stats = JSON.parse(e.data);
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
33 console.log(updated_stats);
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
34 }, false);
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
35 ```
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
36
3643
740870196b97 mod_http_stats_stream: Make global to simplify
Kim Alvefur <zash@zash.se>
parents: 2480
diff changeset
37 # Compatibility
2480
c98b37d6d86c mod_http_stats_stream: Add a README
Kim Alvefur <zash@zash.se>
parents:
diff changeset
38
4595
bac3dae031ee Add note of incompatibility with trunk since 5f15ab7c6ae5
Kim Alvefur <zash@zash.se>
parents: 3643
diff changeset
39 * Prosody \>= 0.11.0
bac3dae031ee Add note of incompatibility with trunk since 5f15ab7c6ae5
Kim Alvefur <zash@zash.se>
parents: 3643
diff changeset
40 * Trunk < [5f15ab7c6ae5](https://hg.prosody.im/trunk/rev/5f15ab7c6ae5)