I find there are several google analytics alternative on the internet.
Now, I wonder if I can create my own google analytics? How to?
do you want to build it from scratch or you want to install a monitoring software?
I suggest you to do some research, there are a lot of articles on this topic.
If, instead, you want to install a monitoring software on the server, then look at tools like GoAccess:
you can get the results as JSON or CSV to create your own templates, or you can use the available interfaces.