Have Prometheus send a SQL Query - mysql

I'm trying to use Prometheus to monitor my MySQL database but can't seem to find an area to add SQL queries. For example, I'd like to run a SQL query which returns a value and then add that value to the graph/send an alert. Is there a way to have Prometheus send SQL queries and retrieve the output?
Thank you

https://github.com/chop-dbhi/prometheus-sql will allow queries to be run against any SQL database that can then be scraped as metrics.

Related

Differences between Qlikview and SQL query results

I have Qlikview installed on my pc and it takes the data from a database.
I want to write an sql query which would take the same data(for automatization).
The problem is that my sql query returns 30+k more records than Qlikview.
I believe, that Qlikview is adding more restrictions than I do in my sql code.
So is there a way to find out what limitations and filters Qlikview is applying when retrieving data, so I could copy these filters to my sql script?

Can we execute Mdx queries on MySql database directly.If yes how?

I want use MDX queries directly against MySQL database. Right now I am using Pentaho's MIS analytics to run the MDX queries.
You can't execute MDX Queries on DB, but the related SQL query can be executed, for that to happen you will have Enable Mondrian Logs in Pentaho. So that it will generate the SQL Query for that particular MDX Query.
Please follow the steps:
Go to \pentaho\WEB-INF\classes.
Edit. Enable all the logs in Log4j File.
Enable the following Tags:
MONDRIAN
MDXLOG
SQLLOG
I'd suspect the answer is no.
You execute MDX against a multi-dimensional structure - MySQL database is relational.
You need to store the data in a multi-dimensional format first - then mdx may be possible.

Convert SQL Server Query to MongoDB Query # Runtime

I am in a situation where I need to convert my dynamically generated SQL Server query to Mongo DB query. Is there any tool/plugin/nuget package available that takes sql server query as input and outputs mongodb query(just like what is done in "www.querymongo.com")?
No
I would add than you don't send interpreted language (sql) than you can adapt according to the database server, but you use a proprietary API :
http://docs.mongodb.org/ecosystem/tutorial/use-linq-queries-with-csharp-driver/
Have created a JS for creating the Mongo queries dynamically, based on the operators selected.

Best way to synchronise data: MySQL -> SQL Server

I have a fairly straight way to copy selective data using SQL like so:
# Courses
DROP TABLE db_node.courses;
CREATE TABLE db_node.courses LIKE db_prod.course_sis;
INSERT INTO db_node.courses SELECT
*
FROM
db_prod.course_sis
WHERE
db_prod.course_sis.enabled = 1
AND db_prod.course_sis.hidden <> 1;
This is easy when I am on the same server with the same db, however I want to run this SQL to get put the final data on the SQL Server.
This isn't just a once off thing, it would need to be handled every hour or so. I am unable to change db's, one will always be MySQL and SQL Server because the data is used in a sharepoint app.
Thanks
There are several third-party tools to make this transition easier.
Check out SSMA here and here.
I'd also look at SQL Studio scheduled tasks to automate the process.

Select * from Database 1 and insert into database 2

I have 2 Database in my VB.net application. I am using 1st database for daily operations. I would like to send one of the table records to online database. How Can I do that? First database is MSSQL Online database is MYSQL. I have created connections already using MYSQL .net connector.
Any Help will be appreciated.
Regards
Have a look at using a Linked Server instance on SQL Server to write the data to MySQL using the four name notation.
SQL SERVER – Explanation and Example Four Part Name
SQL Server Four-part naming
Ok here is a rough set of steps you need to follow
Query the MSSQL database and retrieve the data you want. Storing it in a DataTable may be the best option starting off.
Loop through the DataTable rows and build an INSERT statement that will be run against the MYSQL database.
Execute the command against the MYSQL db.
This is the basics of what you need to do to get a simple working system. Also take a look at Transactions as a way to manage the rollback of data when something goes wrong.
I'm assuming this is a research project If you are planning on using this code in a production system then i would look into a different alternative such as uploading data files to a service attached to the MYSQL database. This would allow you to batch and retry an import when something goes wrong.