coturn / coturn

coturn TURN server project
Other
11.43k stars 2.03k forks source link

Prometheus Exporter for CoTurn #711

Closed Chandramouli-P closed 3 years ago

Chandramouli-P commented 3 years ago

Hello Team,

I would like to know that Is there any good Prometheus exporter library is available for CoTurn?

(Like below for PM2) (NodeJS): https://www.npmjs.com/package/pm2-metrics

If we get all the required parameters by using one library, it becomes very easy to monitor by using Grafana tool. Thank you.

Best Regards, Chandramouli.

Chandramouli-P commented 3 years ago

Hi,

If I understand correctly, First I should install prometheus-client-c library from https://github.com/digitalocean/prometheus-client-c/releases web site. I installed libprom-dev-0.1.3-Linux.deb and libpromhttp-dev-0.1.3-Linux.deb files. Still, Do I need to any thing? When I am trying to run "make" in .tar.gz file, it is giving "Docker" not available error. Can any one help me in installing this library? So, I can see "Prometheus" parameter in CoTurn configuration file.

Thank you.

Best Regards, Chandramouli.

Chandramouli-P commented 3 years ago

Hello,

Good morning and any update would be appreciated. Thank you.

Best Regards, Chandramouli.

misi commented 3 years ago

You need to install libprom and libpromhttp. After you did it coturn will detect these, and after recompile you can use it. I am not sure if the docker updated to contain these libs, so you need to make it manually..

Chandramouli-P commented 3 years ago

Hello @misi ,

Good morning and as you suggested, I followed and it is working now. Here I am posting the documentation for other users:

wget https://github.com/digitalocean/prometheus-client-c/releases/download/v0.1.3/libprom-dev-0.1.3-Linux.deb sudo dpkg -i libprom-dev-0.1.3-Linux.deb wget https://github.com/digitalocean/prometheus-client-c/releases/download/v0.1.3/libpromhttp-dev-0.1.3-Linux.deb sudo dpkg -i libpromhttp-dev-0.1.3-Linux.deb sudo apt install libmicrohttpd-dev sudo apt --fix-broken install sudo dpkg -i libpromhttp-dev-0.1.3-Linux.deb

Thank you.

Best Regards, Chandramouli.

chole488 commented 1 year ago

we installed prometheus and configured to collect metric from coturn server but not working,

Please guide us with installation steps, is there need any exporter to collect coturn server metric.

eakraly commented 1 year ago

@chole488 first please make sure prometheus interface is active:

  1. You run turnserver with --prometheus flag
  2. You can successfully curl http://turnserver_ip:9461/metrics and get some results
chole488 commented 1 year ago

Please find below our turnserver conf, please guide us prometheus config, we installed prometheus another machine - working fine. how to configure here to run turnserver with --prometheus flag

/etc/turnserver.conf

STUN server port is 3478 for UDP and TCP, and 5349 for TLS.

Allow connection on the UDP port 3478

listening-port=3478

and 5349 for TLS (secure)

tls-listening-port=5349

Require authentication

fingerprint lt-cred-mech

We will use the longterm authentication mechanism, but if

you want to use the auth-secret mechanism, comment lt-cred-mech and

uncomment use-auth-secret

Check: https://github.com/coturn/coturn/issues/180#issuecomment-364363272

The static auth secret needs to be changed, in this tutorial

we'll generate a token using OpenSSL

use-auth-secret

static-auth-secret=replace-this-secret

----

If you decide to use use-auth-secret, After saving the changes, change the auth-secret using the following command:

sed -i "s/replace-this-secret/$(openssl rand -hex 32)/" /etc/turnserver.conf

This will replace the replace-this-secret text on the file with the generated token using openssl.

Specify the server name and the realm that will be used

if is your first time configuring, just use the domain as name

server-name=call.cello.dev realm=call.cello.dev

Important:

Create a test user if you want

You can remove this user after testing

user=celloworld:CellWORLD@2143@#

total-quota=100 stale-nonce=600

Path to the SSL certificate and private key. In this example we will use

the letsencrypt generated certificate files.

cert=/etc/letsencrypt/live/stun.call.cello.dev/cert.pem pkey=/etc/letsencrypt/live/stun.call.cello.dev/privkey.pem

Specify the allowed OpenSSL cipher list for TLS/DTLS connections

specify min port and max port

min-port=32769 max-port=65535

Specify the process user and group

proc-user=turnserver proc-group=turnserver

log

log-file=/var/log/turnserver.log

chole488 commented 1 year ago

Please guide us

BaldingVoIP-engineer commented 1 year ago

Hi @chole488 ,

You have to have the c client for Prometheus installed before you run the configure/make

Please see the below, also for anyone else trying to get Prometheus metrics working.

Command list from root on a fresh Ubuntu 20.04.5 LTS instance: apt update apt install -y make git build-essential pkg-config libssl-dev libevent-dev libmicrohttpd-dev libsystemd-dev libhiredis0.14 libmysqlclient21 libpq5 mysql-common sqlite3 wget https://github.com/digitalocean/prometheus-client-c/releases/download/v0.1.3/libprom-dev-0.1.3-Linux.deb wget https://github.com/digitalocean/prometheus-client-c/releases/download/v0.1.3/libpromhttp-dev-0.1.3-Linux.deb sudo dpkg -i libprom-dev-0.1.3-Linux.deb sudo dpkg -i libpromhttp-dev-0.1.3-Linux.deb git clone https://github.com/coturn/coturn.git cd ./coturn Edit configure file if you need to and change config location as required /etc or change the binary location as required eg: /usr - was/usr/local ./configure make && make install Check the binaries are in the correct place under /usr/bin - you will see the turnsever etc bins Add the service file to /etc/systemd/system/coturn.service systemctl enable coturn systemctl start coturn

The above worked for me on an EC2 and you will see prometheus libs in the make output.

Then just test as described above using: curl http://turnserver_ip:9641/metrics or adjust your scrape and you will see them hopefully. (edit: port is 9641)

docjojo commented 1 year ago

if I run

turnserver --log-file stdout --prometheus

I only get the help list as if the command is not found.

I installed coturn with apt do I have to compile it to get prometheus going?

eakraly commented 1 year ago

Hi @docjojo That is correct, you need to build from source.

docjojo commented 1 year ago

I did compile but

when I run

systemctl start coturn

I get

● coturn.service - LSB: coturn TURN Server
     Loaded: loaded (/etc/init.d/coturn; generated)
     Active: active (exited) since Mon 2023-10-16 10:33:37 UTC; 1min 9s ago
       Docs: man:systemd-sysv-generator(8)
    Process: 40125 ExecStart=/etc/init.d/coturn start (code=exited, status=0/SUCCESS)
        CPU: 2ms

and

ss -lna | grep 3478
ss -lna | grep 5349

returns nothing - so coturn is not listening.

when I run

turnserver --log-file stdout --prometheus

I get answer on port 3478 and 9641 but I don't know which turnserver.conf is being used.

Can you help?

eakraly commented 1 year ago

@docjojo

  1. When you run turnserver --log-file stdout --prometheus and it runs meaning now you have a version with prometheus support.
  2. Just running it does not use any config file - it uses hardcoded defaults
docjojo commented 1 year ago

Thanks, it works now, on https://freeturn.net