This paper analyzes the benefits of big data for smart cities and the potential of the knowledge discovery from sensed data. Big data enables real-time systems monitoring, management, optimization and anticipation. In this work we present some examples of applications of big data analysis in two scenarios of smart cities. One of them describes the services provided in the SmartCampus of the University of Murcia. The second example is focused on a tram service scenario where thousands of transit-card transactions should be processed. The results obtained after applying the most appropriate big data techniques in both scenarios show how it is possible to provide efficiently services like the management of the energy consumption and comfort in buildings, and the transport congestion in the context of smart cities.