By default, the service parameters are set in /etc/microimpuls/mistats/configuration.yaml. License - in /etc/microimpuls/mistats/license.yaml.
Environment variables
Some MiStats global server parameters can be redefined into environment variables in the file /etc/microimpuls/mistats.env.
MISTATS CONFIG PATHThe path to the MiStats configuration. By default/etc/microimpuls/mistats/configuration.yaml.MISTATS LICENSE PATH- a path to the license file. By default/etc/microimpuls/mistats/license.yaml.
Example:
MISTATS CONFIG PATH=/etc/microimpuls/mistats/configuration.yaml
MISTATS LICENSE PATH=/etc/microimpuls/mistats/license.yaml
MiStats base
Connect to a separate MiStats database on MySQL or PostgreSQL. Section MISTATS DATABASE.
HOST- base host.PORT- base port.NAME- base name.USER- user.PASSWORD- password.DRIVERMySQL or PostgreSQL driver. For MySQL, the installation example ismysql.
Example for MySQL:
MISTATS DATABASE: HOST: 127.0.0. 1st PORT: 3306 NAME: mistats USER: mistats PASSWORD: . DRIVER: mysql
ClickHouse
Section CLICKHOUSE.
HOST- ClickHouse host.PORT- ClickHouse port. For a client on the same server, port 9000 is indicated in the installation example.DATABASE- base name. In the installation example, thissmarty stats.USER- user.PASSWORD- password.READ POOL SIZE,WRITE POOL SIZEthe size of the pools of connections for reading and writing.READ COMPRESSIONCompress when reading from ClickHouse.TABLES TO CLEARdictionary "table name: maximum age of rows in days" for cleaning.
Example:
CLICKHOUSE: HOST: 127.0.0. 1st Port: 9000 DATABASE: smarty stats USER: smart PASSWORD:
Redis and queue
Redis is needed for the task queue. If established mistats-videoIt also accumulates video viewing tags until they are moved to permanent storage in ClickHouse. Section MISTATS REDIS.
HOST- Redis host.PORT- Port Redis.DBB- Redis base number.
Example:
MISTATS REDIS: HOST: 127.0.0. 1ST PORT: 6379 DB: 0
API
Section MISTATSexcept SMARTY. URL.
MISTATS.HOSTThe address at which the API receives requests.MISTATS. PORT- API port. Default 8095.MISTATS. UVICORN WORKERSThe number of Uvicorn worker processes.MISTATS.DEBUG- start the service in debugging mode.SMARTY. URL- Smarty's basic URL. According to it, MiStats checks authkey video viewing tags. The default value is calculated for Smarty on the same server and port 8000. The actual URL of Smarty is recorded in the config.
Example:
MISTATS: HOST: 0.0.0. 0 PORT: 8095 UVICORN WORKERS: 1 Smarty: URL: http://127.0.0.1:8000
CORS
Its setting is required to send video tags directly from the client portal to the MiStats API. Section CORS.
ENABLED- includes CORS. By defaulttrue. To turn off the CORS, putfalsely.ALLOWED HOSTS- a list of portal sources from which requests are allowed. By default[]: sources not permitted.["*"]any source allows.RESPONSES CACHE SECONDSHow many seconds does the browser remember the CORS response and not ask for permission before each request? The recommended value is not set, you can not specify the parameter for installation.
Example:
CORS: ENABLED: true ALLOWED HOSTS: - https://tv.example.com
License
File /etc/microimpuls/mistats/license.yaml. The content is generated in the personal account of the operator, it must be copied in its entirety.
Example:
KEY: "..." client id:" client name: " valid until: 31.12.2026 features ...
Logs
Paths to files - section LOGS.
- LOGS.LEVEL & #8212; logging level name: DEBUG, INFO, WARNING, ERROR, CRITICAL. By default: INFO
LOGS.MISTATS. ERROR FILE PATH- mistakes.LOGS.MISTATS.ACCESS FILE PATH- access to the API.LOGS.MISTATS.MISTATS FILE PATH- the main service log.LOGS.MISTATS. COMMANDS FILE PATH- teams.LOGS.DATABASE.LOGS ENABLEDLogging SQL queries. By defaultfalsely.LOGS.DATABASE.LOGS FILE PATH- SQL request file. Write whenLOGS ENABLEDequaltrue.LOGS.DATABASE.SLOW QUERY WARNING MSA threshold in milliseconds after which a slow request is written in a warning. It works if the value is greater than 0.
Example:
LOGS: MISTATS: ERROR FILE PATH: ACCESS FILE PATH: . MISTATS FILE PATH: . COMMANDS FILE PATH: DATABASE: LOGS ENABLED: false
Authorization
Television tags from client devices first enter Smarty, and then unload from there to MiStats through the API /stats/push/which requires authorization with a token. Which token Smarty sends is set by the Smarty parameters below. On the MiStats side, this is a section AUTH.
AUTH.API.ENABLEDThis includes checking the API token. For production, leave it on.AUTH.API.TOKENSdictionary of permissible tokens and service names.
JWT is required for MiStats admin.
AUTH. JWT.ENABLEDThis includes JWT authentication.AUTH.JWT.SECRET KEY- JWT signature secret.AUTH.JWT.ALGORITHM- JWT signature algorithm. By defaultHS256.AUTH.JWT.ACCESS TOKEN EXPIRATION TIMEthe lifetime of the access token, in seconds.AUTH.JWT.REFRESH TOKEN EXPIRATION TIMElifetime of the refresh token, in seconds.
Example:
AUTH: API: TOKENS: : smarty JWT: ALGORITHM: HS256
Video viewing
The parameters are relevant for the installed package mistats-video. Tags are first accumulated in Redis, after which the scheduler at intervals VIDEO STATS COMPRESSOR. CALL INTERVAL SECONS queues up compression of completed intervals and their recording in ClickHouse.
VIDEO STATS COMPRESSOR. MAXIMUM MINUTES BETWEEN VIDEO CHECKPOINTSAfter how many minutes without new labels, the viewing is considered complete. By default5. It should not be less than the intervalpush_stat_intervalportal.VIDEO STATS COMPRESSOR. PUSH CHUNK SIZEThe size of the pack that the unfinished tags return to Redis. By default1000.VIDEO STATS COMPRESSOR. CHECKPOINTS TO PROCESS LIMITHow many labels are taken from Redis in one iteration of compression By default10000.VIDEO STATS COMPRESSOR. CALL INTERVAL SECONS- compression start interval, in seconds. By default600.VIDEO STATS COMPRESSOR. TIME LIMIT SECONDSThe maximum time of one iteration of compression, in seconds. By default60.VIDEO STATS COMPRESSOR.RETRIES COUNTNumber of repeated attempts in case of compression error. By default2.VIDEO STATS COMPRESSOR.RETRIES AFTER SECONDSpause before the next attempt, in seconds. By default5.VIDEO STATS COMPRESSOR.DONT RETRY AFTER SECONDSAfter how many seconds in the queue or at work do not repeat. By default540.SMARTY.VIDEO STATS AUTH ENABLEDCheck authkey in video viewing requests. Checking's onSMARTY. URL.SMARTY. AUTH CACHE TTLhow many seconds is a successful authkey check cached.VIDEO STATS. COMPLETE VIEW MIN PERCENTThe minimum percentage of duration from which viewing is considered complete. For a movie, it's a fraction of one movie per account, for a series, it's a fraction of each episode.
Example:
VIDEO STATS COMPRESSOR: MAXIMUM MINUTES BETWEEN VIDEO CHECKPOINTS: 5 PUSH CHUNK SIZE: 1000 CHECKPOINTS TO PROCESS LIMIT: 10,000 CALL INTERVAL SECONDS: 600 TIME LIMIT SECONDS: 60 RETRIES COUNT: 2 RETRIES AFTER SECONDS: 5 DONT RETRY AFTER SECONDS: 540
Reports
VIDEO STATS REPORTS. TIME LIMIT SECONDSmaximum time to generate a video report, in seconds.VIDEO STATS REPORTS. AGE LIMIT SECONDShow many seconds can the task of such a report live in line.SMART STATS. PROGRAM RATING LIMIThow many programs are included in the reportprogram ratings report. Meaningnullremoves the restriction.SMARTY STATS REPORTS TIME LIMIT SECONDSMaximum generation time of Smarty Stats report, in seconds.SMARTY STATS REPORTS AGE LIMIT SECONDShow many seconds can the task of such a report live in line.
Smarty base
Section SMARTY DATABASE Connect to the Smarty database.
HOST,PORT,NAME,USER,PASSWORD- address, database name, user and password.DRIVER- base driver.SSL ENABLED- SSL when connected. Relevant to the drivermysql.
Task line
Section DRAMATIQ — queue configuration dramatiq.
- MISTATS.PROCESS COUNT & #8212; number of Mistats queue processes. Default 2.
- MISTATS.THREADS COUNT & #8212; number of threads per process. Default 8.
- MISTATS.WORKER SHUTDOWN TIMEOUT SECONDS & #8212; how many seconds to wait for the workman to stop? Default is 75.
Smarty options related to MiStats
IN INSTALLED_APPS must be a module viewstatsThe Smarty license must contain it. After editing the config, you need to restart uWSGI.
Television tags from client devices first enter Smarty, and then unload from there to MiStats by the management team push stats.
VIEWSTATS MISTATS BASE URLMiStats API address, same host and port asMISTATS.HOSTandMISTATS. PORT.VIEWSTATS BUFFER MAX COUNTHow many tags does Smarty store in its Redis before uploading them to MiStats? In the example installation2500000.VIEWSTATS MAXIMUM MINUTES BETWEEN INTERVALSHow many minutes without continuing the TV viewing label is considered complete. Recommended value:5as many minutes as inpush_stat_intervalby default. If the portal interval is increased, this value is raised and not left less than a new interval in minutes.VIEWSTATS MISTATS USE NEW AUTHSelects the unloading authorization scheme in MiStats. Included sends a token fromVIEWSTATS MISTATS API TOKENheadlinedX-API-Token. Turned off usesVIEWSTATS MISTATS ACCESS TOKEN.VIEWSTATS MISTATS API TOKEN- API token for the new scheme. The default value coincides with the record inAUTH.API.TOKENSon the MiStats side.VIEWSTATS MISTATS ACCESS TOKENtoken of the previous authorization scheme.
Portal
push_stat_interval- the interval of sending tags by the portal, in milliseconds. By default300000That's 5 minutes. With the same period put cronpush stats. Description of the parameter - in portal settings.mistats api urlMiStats API address for video viewing tags. It's for the device. An extra slash at the end of the address is acceptable. Video viewing tags go to this API directly, bypassing the Smarty API.
Teams
Utility mistats manage put together mistat-base into /usr/local/bin. mistat manage help it only shows commands of packets installed.
venv installcreates an environment in/usr/share/microimpuls/venvs/mistats.requirements- addictive.venv remove- removes the environment.version- displays packet, build and interpreter versions.pipit causes the pip of the current environment.start,stop,restart,status- manage servicesmistats,mistats queueandmistats scheduler.migrate clickhouse- rolls migration ClickHouse. Flag-dry-runit shows unused migrations and does not change the base.migrate mistats db- rolls migration base MiStats. Flag-dry-runit works the same way.ttl --days NSpecifies the storage period of data in ClickHouse tables, in days. Launched from root:sudo mistats manage ttl --days N.cleanupDeletes lines that have already expired. Launched from root:sudo mistats manage cleanup.compress videostats- once puts in line compression of video viewing labels, without waiting for the scheduler interval. We need to runmistats queue.check- checks the interpreter, configuration, availability of Redis, ClickHouse and MiStats databases, migration status.queue status- shows the status of the queue and the planner.create user— creates a user in admin. Mandatory options:login,name,available-client. Optional:email,inactive(if — is transmitted; an inactive user will be created),superuser(If transferred, the user will have advanced features in the admin). The password is set interactively after the script is called.
Smarty teams that work with MiStats data:
push statsUploads completed TV viewing tags from Smarty to MiStats. The cron interval coincides withpush_stat_interval.
Selections and sorting by television are described in integration with MiStats:
create_channel_sorting_by_popularity- creates sorting channels by tv viewing.create_channel_election_by_popularity- creates a selection of popular tv channels.create_epg_election_by_popularity- creates a selection of popular television programs.create vodpvr selection by popularity- creates a selection of popular films archive video library on television.create video election by popularity- creates a selection of popular films and TV series on video viewing. The team is in Smarty 2.12. Description: In integration with Smarty.
